Session 1 · 90 min
How can a small pin switch a motor it cannot power?
The transistor as a switch: a TIP120 on the low side (between the motor and GND), a 1 kΩ base resistor that keeps the pin's current small (a pin is rated 20 mA, 40 mA at most), the 1N4001 flyback diode across the motor, and the motor's own battery (4 × AA alkaline in a holder with a power-off switch) with its − joined to the board's GND. PWM on D9 sets the speed.
In the studio
Hands-on
In Control a motor, trace the signal path (D9 → 1 kΩ → base) and the power path (battery + → motor → collector → emitter → GND), then look at its two unsafe faults (no driver; the diode the wrong way round) and say what each would do. On the bench, with the holder switched off and unplugged and USB unplugged, build the same circuit: the TIP120 printed face towards you, legs down (base, collector, emitter from the left); the diode's stripe to the battery +. Clamp the motor so its shaft turns freely. After the adult check, plug in USB, upload, connect the battery last and switch it on; step analogWrite(9, …) up from 0 in tens and note where the motor starts.
Starting code: Control a motor's sketch (Copy code in the lab's code panel): analogWrite() on pin 9 sets the speed.
Pins
- D9
- TIP120 base, through the 1 kΩ resistor
Evidence to collect
A power-path drawing with the signal path and the power path in two colours, and a table of analogWrite() values: turning or not, with the start value marked and compared with the guide's “about 1/2 its rated voltage”.
- Predict
- Before power, predict the analogWrite() value where the motor starts, from the guide's “about 1/2 its rated voltage”.
- Debug
- If it never turns, switch off and unplug, then check one connection at a time against the drawing, starting with the battery − to GND.
- Reflect
- Why does the pin's current stay small while the motor's is large?
⚠ Adult checks before power-on: The motor battery is a separate holder of 4 × AA alkaline cells (1.5 V each, about 6 V fresh) in a holder whose on/off switch is the power-off switch: its power-off switch is off and it is unplugged while wiring, then connected last. The diode's stripe faces the battery +. The TIP120's metal tab is its collector (pin 4 on the datasheet), so it touches no other part or wire; its emitter goes to GND and the battery − to the board's GND; the motor is clamped. Only the 1 kΩ resistor joins D9 to the circuit, and nothing else uses D9. Keep the motors clamped, wheels in the air, before switching the motor battery back on: the sketch keeps running on USB, so they take its last command at once. No wire is moved, pulled or plugged in while anything is powered: power-off switch off and battery unplugged first, then USB.
Works towards: Motors in code, Power budget