Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsiTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Do not connect a motor directly to an ATtiny GPIO pin. Use the ATtiny only as a control signal for an external power transistor. The motor needs its own suitable supply, a correctly selected logic-level N-channel MOSFET, a flyback path, careful grounding and local decoupling. Most failures—resets, weak starting, hot transistors, erratic PWM and damaged components—come from one of those details.
First identify the motor and ATtiny
The circuit in this guide is for a brushed DC motor running in one direction with on/off or PWM control. A single low-side MOSFET cannot reverse it; use an H-bridge or motor-driver IC for forward/reverse operation. Stepper and BLDC motors require their own dedicated drivers and control algorithms.
ATtiny parts are not interchangeable. ATtiny24/44/84, ATtiny25/45/85, ATtiny402/412 and ATtiny1604/1606/1607 families differ in pin functions, timers, voltage limits and electrical ratings. Check the exact device data sheet, manual and errata in Microchip’s tinyAVR documentation before choosing a PWM pin or supply voltage.
Recommended Free Tools
The safe low-side circuit
+V MOTOR ── motor ──+── drain N-MOSFET source ── common GND
| |
+─|<|───+ flyback diode
(cathode to +V MOTOR, anode to drain)
ATtiny PWM ── 47 Ω ── gate
|
47 kΩ
|
GND
ATtiny VCC ── 100 nF ── GND
+V MOTOR ── bulk capacitor ── GND
- Connect the motor between motor-supply positive and MOSFET drain.
- Connect MOSFET source to the motor-supply ground.
- Drive the gate from an ATtiny GPIO/PWM pin through a small series resistor.
- Add a gate-to-ground pull-down so the MOSFET stays off during reset or power loss.
- Place the diode directly across the motor: cathode to motor positive, anode to the drain/motor-low node. Adafruit’s MOSFET motor reference uses this same kickback-protection principle.
- Join ATtiny ground and motor ground deliberately, and bypass both supplies locally.
The 22–100 Ω gate resistor and 10–100 kΩ pull-down are starting ranges, not universal values. The diode’s reverse-voltage, repetitive-current, peak-current and thermal ratings must be derived from the motor supply and measured current.
#1 Best Overall
- Support for the . IDE 1.0+ (OSX/Win/Linux).
- Power via USB or External Source - 5v or 7-35v (automatic selection).
- On-board 500ma 5V Regulator.
- Built-in USB (and serial debugging).
- 6 I/O Pins (2 are used for USB only if your program actively communicates over USB, otherwise you can use all 6 even if you are programming via USB).
Ten common causes of failure
1. The motor is connected to an ATtiny pin
An arrangement such as ATtiny pin → motor → GND can exceed GPIO current, inject transients and collapse VCC. The ATtiny24A/44A/84A specifications, for example, use 10 mA-per-pin tests at 5 V and 5 mA at 3 V, with additional total-port limits; these are logic-output test conditions, not motor-drive ratings. See the applicable Microchip electrical specifications. The GPIO should drive only the MOSFET gate.
2. MOSFET pins or polarity are wrong
Package pin order is not standardized. Verify gate, drain and source in the exact MOSFET data sheet; never assume a TO-220 or SOT-23 layout. Reversed drain/source connections, a gate tied to the drain, or a source not tied to common ground can produce immediate failure or a permanently-on motor. Also verify that a module’s signal, VCC and GND labels match its schematic.
3. The MOSFET is not enhanced at the ATtiny voltage
VGS(th) is a low-current threshold test, not a useful on-state guarantee. Select a device with RDS(on) specified at the actual gate voltage—2.5 or 3.3 V for a low-voltage ATtiny, for example—plus adequate VDS, current, gate-charge and thermal ratings.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchRank #2
- Digispark kickstarter Attiny85 IDE MINI USB Development Board 5V Attiny Microcontroller Programmer Module for
Conduction loss is approximately P = IRMS2 × RDS(on). At 2 A and 0.08 Ω it is about 0.32 W; at 5 A it is about 2 W. Startup and stall current, not no-load current, determine whether the transistor survives. If gate charge is high, PWM is fast or several MOSFETs are used, an external driver such as TI’s DRV8701 can supply substantially more gate-drive current than an MCU pin.
4. The flyback diode is missing, reversed or too small
A brushed motor stores magnetic energy. When the MOSFET turns off, the diode provides the current-decay path and limits voltage stress. A missing or backward diode, a diode placed across the MOSFET instead of the motor, long diode wiring, or inadequate peak-current and voltage ratings can destroy the MOSFET. A conventional diode gives slower current decay; a TVS clamp, active recirculation or integrated driver may be preferable when faster dynamic response is required.
5. Motor current collapses the supply
Startup and stall can draw several times running current. Use a supply rated for that peak, route high-current motor paths separately from the ATtiny VCC trace, and keep the switching loop short. Put a 100 nF ceramic capacitor close to the ATtiny VCC pin and bulk capacitance near the motor supply and MOSFET loop. Microchip’s decoupling guidance stresses short, local capacitor placement.
Rank #3
- The Digispark is an Attiny85 based microcontroller development board similar to the line, only cheaper, smaller, and a bit less powerful. With a whole host of shields to extend its functionality and the ability to use the familiar for Arduino IDE the Digispark is a great way to jump into electronics, or perfect for when for Arduino is too big or too much.
- The Digispark is shipped fully assembled except for the two included and easy to solder headers.
- Support for the Arduino IDE 1.0+ (OSX/Win/Linux)
- Power via USB or External Source - 5v or 7-35v (12v or less recommended, automatic selection)
- 6 I/O Pins (2 are used for USB only if your program actively communicates over USB, otherwise you can use all 6 even if you are programming via USB)
6. The ATtiny supply is out of range or noisy
Motor voltage, ATtiny VCC and gate voltage are separate design decisions. A 9 V motor rail cannot be connected directly to a 5 V-only circuit, and a fully charged battery may exceed the MCU limit. The ATtiny414 product page lists 1.8–5.5 V operation, but that range must not be generalized to other models; verify your exact part at Microchip. A regulator must supply the MCU and peripherals, while the motor uses a motor-capable rail.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
7. Grounds are not common
Gate voltage is measured relative to MOSFET source. Without a common ATtiny/motor ground, the GPIO signal has no defined reference. Join grounds at a deliberate, low-impedance point rather than forcing motor current through thin MCU ground traces.
8. The gate floats or switches slowly
A pull-down keeps the MOSFET off during reset, bootloading, programming or ATtiny power loss. The series resistor limits GPIO peak current and ringing, but too much resistance slows switching and increases heat. Confirm gate voltage relative to source with an oscilloscope in demanding designs.
Rank #4
- 2.4GHz Dual Mode WiFi + Bluetooth Development Board
- Support LWIP protocol, Freertos;ESP32 is a safe, reliable, and scalable to a variety of applications
- SupportThree Modes: AP, STA, and AP+STA
- Ultra-Low power consumption, Compatible with Arduino IDE
- 1PCS 30Pin ESP32 Development Board 2.4GHz WiFi Dual Cores Microcontroller Integrated with Antenna RF Low Noise Amplifiers Filters
9. PWM is on the wrong pin or timer
Hardware PWM normally provides steadier timing and less CPU load than delay-based software PWM, but timer registers, output-compare channels and pin multiplexing differ by ATtiny model. Confirm the selected peripheral in that device’s data sheet. A motor that runs at full speed may have its gate tied high or its output-compare function mapped to another pin; humming may indicate unsuitable PWM conditions, insufficient startup duty or excessive load.
10. The mechanical load is excessive
Binding bearings, a jammed gearbox, an obstructed fan or pump, or an overloaded mechanism can create an electrical-looking fault. Measure no-load, normal-load, startup and stall current. A multimeter may miss the startup peak; use a current probe, a shunt with suitable measurement circuitry or a bench supply with current readout.
Free tools Windows power users keep installed
One-click scans. No signup required.
Power, layout and thermal checks
- Keep the motor-current loop (supply, motor, MOSFET and diode) physically small.
- Keep the drain/switch node away from the gate trace, ADC wiring and clock or communication lines.
- Use short, wide copper and connectors rated for stall current.
- Provide a real thermal path: package dissipation depends on PCB copper, ambient temperature and duty cycle.
- Separate logic and motor supplies when practical; a single supply can work only with adequate peak current, regulation, capacitance and layout.
Bring-up procedure that limits damage
- Run the ATtiny alone and verify VCC, reset, clock and intended PWM output.
- With the motor disconnected, measure gate-to-source voltage: it should reach a clear high level and return near 0 V.
- Recheck the MOSFET pinout and install the correctly oriented diode.
- Use a current-limited bench supply at the motor’s correct voltage.
- Apply 100% duty briefly. Check starting, supply voltage, resets and MOSFET temperature.
- Test PWM at low duty, then increase it gradually. Many motors need a higher startup duty than their running duty.
- Add mechanical load slowly while monitoring current, temperature and ATtiny behavior.
- Perform a controlled stall only with a current-limited setup capable of tolerating it, and never leave it unattended.
- If failures persist, inspect the drain waveform. Overshoot points to inadequate clamping, wiring inductance, layout or diode selection.
Software protections worth adding
motor_off();
configure_gpio_as_output_low();
configure_hardware_pwm();
wait_for_power_stabilization();
for (duty = 0; duty <= startup_duty; duty += STEP) {
set_pwm_duty(duty);
delay_ms(RAMP_INTERVAL);
}
while (running) {
if (overcurrent() || timeout() || fault_detected()) {
motor_off();
enter_fault_state();
}
}
This is model-independent pseudocode. Add a startup ramp, a maximum duty limit where overload is possible, motion timeouts, watchdog recovery, suitable brownout detection and a fault state that disables the MOSFET. Implement the actual PWM registers only after identifying the exact ATtiny.
When a motor-driver IC is the better choice
| Approach | Advantages | Use it when |
|---|---|---|
| One MOSFET and diode | Few parts, simple one-direction PWM, flexible component choice | Small brushed motor and validated current, thermal and EMI behavior |
| Integrated driver | H-bridge direction control, current regulation or sensing, stall and thermal protections | Reversal, significant startup/stall current or a need for robust fault handling |
| External gate driver | Fast, strong gate charge/discharge for external MOSFETs | High current, high PWM frequency or bridge designs |
Examples include the 1.65–12 V DRV8213 with current sensing, regulation and stall detection; the 4.5–35 V DRV8231A; and the 6.5–50 V DRV8872. Their advertised peak ratings are not automatically continuous thermally sustainable currents; check package, PCB, ambient and duty-cycle limits. TI’s TIDA-00365 illustrates a more protected brushed-DC design.
Quick Recap
Symptom-to-test checklist
| Symptom | Likely causes | First test |
|---|---|---|
| Motor only hums | Low startup duty, unsuitable PWM, weak supply or mechanical load | Measure startup current and apply a controlled duty ramp |
| ATtiny resets at start | Supply dip, ground bounce, brush EMI or inadequate decoupling | Observe ATtiny VCC during startup and separate current paths |
| MOSFET overheats | Insufficient gate drive, excessive current, slow switching or poor thermal path | Verify RDS(on) test voltage, gate waveform and loaded current |
| Speed is erratic | Software-PWM jitter, unstable supply or brush noise | Verify hardware PWM and monitor VCC and drain noise |
| Motor never turns off | Floating gate, wrong pinout or incorrect GPIO mode | Measure gate-to-source voltage while off |
| Runs full speed regardless of PWM | Wrong timer/pin mapping or gate tied high | Probe the actual MOSFET gate and compare pin multiplexing |
| MOSFET fails immediately | Missing/reversed diode, drain overshoot or source/drain error | Check diode polarity and drain waveform |
| Motor direction is wrong | Motor leads reversed | Swap leads for a fixed direction; use an H-bridge for electronic reversal |
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

