← Power and motors

Why a motor can't run from a pin

A pin is a signal, not a power supply: it can give about 20 mA, and a motor needs hundreds. The pin switches a transistor, and the transistor switches the motor's own battery. A diode across the motor catches the spike when it switches off.

An LED on pin 9 lights perfectly. Swap it for a small motor, change nothing else, and nothing happens, except maybe a damaged Arduino. What's different?

Current is measured in milliamps (mA). An Uno pin can safely give about 20 mA, and 40 mA at most. An LED needs about 10. A small 6 V gear motor draws about 150 mA turning, and about 700 mA as it starts.

WidthMore contexts, same idea.
PredictRead the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.

Motor on a pin

A small motor is wired from pin 9 to GND. The sketch sets pin 9 HIGH. The motor…

TryTry it on the board and compare the result with your prediction.

Try: wire it straight

Try it yourselfYour edits are saved in this browser.

Switch pin 9 on. Does the motor turn? Compare the current it asks for with what a pin can give.

Use the board. This ticks when you get there.

InvestigateWork out why it happens, one step at a time.

Worked example: the pin only switches

Worked exampleBefore each step, say what you think comes next.
  1. pin 9→1 kΩ→transistor\text{pin 9} \to 1\text{ k}\Omega \to \text{transistor}The pin gives about 4 mA, only to switch the transistor on.

Now: how far over is a pin when it tries to run the motor itself?

The motor needs 700 mA to start. A pin can safely give 20 mA. How many times too much is that?

Sam's motor won't turn on pin 9. Click the line where Sam's reasoning first goes wrong.

ModifyChange the problem on purpose and see what happens.

Vary: switch it off

Try it yourselfYour edits are saved in this browser.

Switch the motor on, then off. What does the board warn you about?

Use the board. This ticks when you get there.

Fit the diode, then switch the motor on and off again.

Use the board. This ticks when you get there.

Modify TypicalChange the problem on purpose and see what happens.

Build it in Tinkercad

PractiseA few on your own, to check you have it.

Which can a pin drive?

Sort each part: straight from a pin, or through a transistor or driver?

An LED with a 220 Ω resistor (about 15 mA)
A small DC gear motor (150 mA running)
A piezo buzzer (a few mA)
A 12 V LED strip (500 mA)
A servo's signal wire (its power from 5V)

MakeMake your own problem using what you have learned. Expect a few tries; that is normal.

Wire it safely

Try it yourselfYour edits are saved in this browser.
Need a hint?

Two problems: the pin's current, and the spike at switch-off.

Another hint

Use a transistor and a battery, and fit the diode.

Another hint

Then switch the motor on.

Change this circuit so the motor runs with the pin safe and the transistor protected.

Use the board. This ticks when you get there.

For teachers

Students try a motor straight on pin 9, compare the 700 mA it asks for with the 20 mA a pin gives, follow the two currents in a transistor circuit, see and fix the switch-off spike with a diode, and sort parts by whether a pin can drive them. About 40 minutes.

Open the teacher guide: answers, solutions, slides and a worksheet.

Students will be able to

Before class

Model: Uno pin 20 mA recommended, 40 mA absolute maximum; motor 150 mA running, 700 mA starting (a small 6 V TT gear motor; check your kit's datasheet). In reality a pin asked for more sags and can be damaged; the board shows the current asked for.

Safety: never wire a motor straight to a pin on real hardware. Unit 4 (this course) is Years 9–10.

Running the lesson

  1. Predict: ask what is different about a motor and an LED, apart from what it does.
  2. Worked example: trace both loops in two colours.
  3. Vary: the spike is invisible on real hardware until something dies; say so.

The hard part (on purpose)

Students reach for the code first. Make 'power before code' the rule of the unit.

When students get stuck

Stretch and support

Stretch: A MOSFET (such as the IRLZ44N) can switch several amps with almost no gate current. Why would that suit a bigger motor?

Support: A two-column card: signal (pin, mA) and power (battery, hundreds of mA).

Where it leads

Next: Motor drivers (both directions and speed).

Sources

What each step is for

Now you can
Next lesson2. Motor driversA motor driver (an H-bridge) lets two pins choose the direction: IN1 HIGH and IN2 LOW is forwards, swapped is backwards, the same is stop. A third, PWM pin on ENA sets the speed with analogWrite. Two jobs, two kinds of signal.