Arduino Learning Studiorobotics pathway

R13-U1 · usually age 13 · Robotics Engineers

Mobile Robot Hardware

What safely controls two motors?

Pilot unit plan · 6 sessions · not yet classroom-validated

Build: Rover with a proper dual motor driver

From one motor switched by a transistor to a two-motor rover on a TB6612FNG driver: the power path and its own alkaline AA battery with a power-off switch, a shared GND, a power budget, a firmly built chassis, and motor functions with parameters. The unit ends with the rover driving forward, turning and stopping on command.

  • Act
  • Power and safety

Who it is for

Age is a starting point, never a limit. A learner who can show what this unit starts from can begin here at any age.

How they learn
By reading and changing real Arduino sketches, predicting, testing in a model, then building and testing the real circuit.
The adult's role
An adult checks every circuit and anything that moves before it is powered.
Session
75–90 minutes
Hardware
Arduino Uno R3 or compatible (5 V). The adult checks the power circuit and the motor driver. Motors never run from a pin; share GND between supplies.

Starts from

Builds, and what it is the input for

In the studio today

After R13-U1 to U3, start the Arduino Rescue Rover course at session 10; sessions 5–9 become a quick review. Open the course →

The labs run a model of each sketch in the browser. They prepare the real build; they never count as a working circuit.

Sessions

  1. 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

  2. Session 2 · 90 min

    What does each pin of a dual motor driver do?

    The TB6612FNG: VCC (logic, from 5V) and VM (the motor battery: 4.5–13.5 V, and at least 5 V for its 1.0 A rating); STBY, which must be HIGH; and for each motor two direction inputs and a PWM input. Its modes: two directions, short brake (both inputs HIGH) and stop (outputs off, the wheel coasts).

    Hands-on

    In Steer with two motors, predict, then test, what each row of the driver's table does to one wheel. On the bench, with everything unpowered, tape or clamp the two motors to a wooden block so their wheels turn in the air (the chassis comes in session 4). Still unpowered, wire the driver as the lab's “Build it for real” view shows: VCC → 5V, GND → GND, STBY → D3, left motor PWMA D5, AIN1 D4, AIN2 D7, right motor PWMB D6, BIN1 D12, BIN2 D11, then the motor battery through its power-off switch to VM, battery − to GND. Check the breakout's printed labels against the guide. Change the sketch's command to run one mode at a time for two seconds each; upload, then switch the motor battery on and fill in what each wheel did.

    Starting code: Steer with two motors' sketch (Copy code in the lab's code panel): STBY on D3 and one helper per motor.

    Pins

    D3
    driver STBY
    D4
    driver AIN1 (left motor)
    D5
    driver PWMA (left motor)
    D6
    driver PWMB (right motor)
    D7
    driver AIN2 (left motor)
    D11
    driver BIN2 (right motor)
    D12
    driver BIN1 (right motor)

    Evidence to collect

    A driver table in the learner's own words: inputs (IN1, IN2, PWM, STBY) → what the wheel did, for forward, backward, short brake, stop and standby, with the observed difference between braking and coasting.

    Predict
    Before each mode, predict whether the wheel will stop quickly or roll on.
    Debug
    If neither wheel moves, check STBY first: it must be HIGH, or the driver stays in standby.
    Reflect
    When would a rover want to brake rather than coast?

    ⚠ Adult checks before power-on: The motor battery reaches the driver's VM only, through its power-off switch; the board's 5V goes to the driver's VCC only; every GND is joined. The breakout's labels match the guide (if they do not, stop). The motors are fixed to the block, wheels in the air; the power-off switch is off and the battery connected last, after the upload. 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

  3. Session 3 · 75 min

    How much current do the motors need, and for how long?

    A power budget: what each motor draws, its stall current against the driver's 1.0 A per channel, the battery's capacity in mAh, and why the board is not powered from the motor battery. Motors draw the most current when they start or are loaded, much less once running. Cells in series add their volts but keep one cell's capacity.

    In the studio

    Hands-on

    In Control a motor, compare a fresh and a run-down battery: what changes at the same speed setting? Then list the loads on the motor battery with the current each data sheet or label gives: each motor's stall current and running current. Check each stall current against the driver's 1.0 A per channel. Estimate the run time in hours: one cell's capacity in mAh ÷ the two motors' running current in mA. Four cells in series keep one cell's mAh, so do not add them; alkaline cells often print no mAh, so the adult gives the figure. The board runs from USB or its own pack, so its current is not in this sum. Then, with the motors still on their block, upload your session 2 sketch with a greeting added in setup(). Open the Serial Monitor first and wait for the greeting (opening it restarts the UNO); only then switch the motor battery on, and count any greeting that appears from then on while both motors start at once.

    Starting code: The learner's session 2 sketch, with Serial.begin(9600) and a greeting printed in setup().

    Evidence to collect

    A power-budget table: each load on the motor battery, its current and where the figure came from, the stall check against 1.0 A, the run time in hours with the working shown, and the number of greetings after the motors started.

    Predict
    Predict the run time in hours, and whether a greeting will appear again when both motors start.
    Debug
    If a greeting appears again after the motors start, the board restarted: check that the motors run only from their own battery and that every GND is joined.
    Reflect
    What would you change to make the batteries last a whole session?

    ⚠ Adult checks before power-on: The motor battery reaches the driver's VM only, through its power-off switch; the board's 5V goes to the driver's VCC only; every GND is joined. The motors stay on their block, wheels in the air; the power-off switch in reach. 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. If anything gets warm: switch off or unplug at the holder, don't touch it, tell the adult.

    Works towards: Power budget

  4. Session 4 · 90 min

    Where does everything go on the rover?

    The chassis: square and firmly fastened; the motor battery holder with its power-off switch where a learner can reach it while the rover moves; the board's own power (USB on a tether, or its own 6 × AA pack in the barrel jack, never the 5V pin); wires tied down so none can be pulled loose; power and signal wires kept apart; the tools used safely.

    Hands-on

    With every battery unplugged and USB unplugged, move the motors from their block to the chassis and fit the wheels and castor; fix the board, the breadboard with the driver and the motor battery holder; put the power-off switch at the top or the back, in reach. Use the tools as the adult check says, with eye protection on when cutting cable ties. Still unpowered, rewire the driver onto the chassis, following Steer with two motors' “Build it for real” view again, and tie the wires down. Still unpowered, pull each wire gently: none comes loose. Then lift the rover, wheels in the air, upload your session 2 sketch, switch the motor battery on and run it again: both wheels must do what your table says.

    Starting code: The learner's session 2 sketch, unchanged.

    Pins

    D3
    driver STBY
    D4
    driver AIN1 (left motor)
    D5
    driver PWMA (left motor)
    D6
    driver PWMB (right motor)
    D7
    driver AIN2 (left motor)
    D11
    driver BIN2 (right motor)
    D12
    driver BIN1 (right motor)

    Evidence to collect

    A labelled drawing or photo of the chassis (the rover only, no people): battery holder, power-off switch, board, driver and where the power and signal wires run, and session 2's table checked again on the chassis.

    Predict
    Will both wheels still match your session 2 table after the move to the chassis?
    Debug
    If a wheel turns backward for “forward”, switch the motor battery off, unplug it and USB, and swap that motor's two leads.
    Reflect
    Which wire on your chassis is most likely to come loose, and how did you stop it?

    ⚠ Adult checks before power-on: The motor battery reaches the driver's VM only, through its power-off switch; the board's 5V goes to the driver's VCC only; every GND is joined. Chassis tools: screwdrivers pushed away from hands; side-cutters cut cable ties flush, eye protection on, sharp ends turned in; hot glue low-temperature or adult-only (it burns); soldering or drilling adult-only. The power-off switch is tested off before the rover is powered. Lift the rover (wheels in the air) before switching the motor battery back on: the sketch keeps running on USB, so the wheels 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

  5. Session 5 · 90 min

    How can one function drive both wheels?

    Functions with parameters, written outside setup() and loop(): a helper per motor that sets its two direction inputs and its PWM, then forward(speed), spinLeft(speed) and a brake function built from them. One command in one place.

    Hands-on

    In Steer with two motors, read how its sketch drives each motor through a helper with three parameters (in1, in2, speed). Start from that sketch and write forward(speed), spinLeft(speed), spinRight(speed) and a brake function with both inputs HIGH. Call them from loop() in a short sequence (forward 1 s, brake 0.5 s, spin 0.5 s, brake). Upload and run it first with the rover lifted, wheels in the air; then on the floor at the lowest value that starts both wheels, never above 160 of 255, with a learner's hand at the power-off switch.

    Starting code: Steer with two motors' sketch (Copy code in the lab's code panel): its helper per motor.

    Evidence to collect

    The sketch with each function explained in the learner's words (what it takes, what it does), and a command table: function call → what each wheel did, lifted and on the floor.

    Predict
    What changes if you halve the speed parameter of forward(speed)?
    Debug
    If one wheel does the opposite of the command, look at that motor's helper call before touching any wire.
    Reflect
    What would you have had to change without the functions?

    ⚠ Adult checks before power-on: The motor battery reaches the driver's VM only, through its power-off switch; the board's 5V goes to the driver's VCC only; every GND is joined. Lifted for the first run of every new sketch; then on the floor at the lowest value that starts both wheels, never above 160 of 255, with the power-off switch in reach and a clear area. Lift the rover (wheels in the air) before switching the motor battery back on: the sketch keeps running on USB, so the wheels take its last command at once.

    Works towards: Functions, Motors in code

  6. Session 6 · 90 min

    Can the rover go forward, turn and stop when we tell it to?

    Demonstrating the rover: forward, a measured turn and a stop, done by the learner without help, after the learner's own pre-power check; the battery reading as a gate; troubleshooting one fault at a time.

    In the studio

    No studio lab: this session is off-screen.

    Hands-on

    Start from your session 5 sketch. Run your pre-power check aloud, in order: (1) the power-off switch is off; (2) the driver's wiring matches the guide (STBY D3; PWMA D5, AIN1 D4, AIN2 D7; PWMB D6, BIN1 D12, BIN2 D11); (3) every GND is joined (board, driver, battery −); (4) still unpowered, no wire comes loose when tugged gently; (5) the rover is lifted, wheels in the air. Then switch the motor battery on and measure it on DC volts at the breadboard rails it feeds: below 5.0 V, replace the cells before any run (the driver's 1.0 A rating needs VM≥5V; a run-down alkaline pack also falls below 5 V). On the floor, find how long a spin must run for a quarter turn at your speed (three tries, take the average). Then demonstrate on your own: drive forward about 50 cm, turn a quarter turn, stop, and switch the motor battery off.

    Starting code: The learner's session 5 sketch, with the turn time found on the floor.

    Pins

    D3
    driver STBY
    D4
    driver AIN1 (left motor)
    D5
    driver PWMA (left motor)
    D6
    driver PWMB (right motor)
    D7
    driver AIN2 (left motor)
    D11
    driver BIN2 (right motor)
    D12
    driver BIN1 (right motor)

    Evidence to collect

    The unit's evidence: the learner independently demonstrates forward, turn and stop, seen by the adult, with the learner's five-step pre-power check, the turn times and the battery readings before and after.

    Predict
    Predict the battery reading after the demonstration, from your power budget.
    Debug
    If something goes wrong, switch the motor battery off, change one thing at a time and say what you changed.
    Reflect
    Measure the battery again: how close was your prediction, and is it still above 5.0 V?

    ⚠ Adult checks before power-on: The motor battery reaches the driver's VM only, through its power-off switch; the board's 5V goes to the driver's VCC only; every GND is joined. For the reading: red lead in the V/Ω socket, never 10A; probes go on breadboard rows or rails, not at the header pins. The learner runs the five-step pre-power check; the battery reads at least 5.0 V before any run; the power-off switch is tested before the first floor run; on the floor at the lowest value that starts both wheels, never above 160 of 255, a clear floor and no one's feet in the way. Lift the rover (wheels in the air) before switching the motor battery back on: the sketch keeps running on USB, so the wheels take its last command at once.

    Works towards: Motors in code, Functions, Power budget

Materials

  • Per group: Arduino Uno R3 (or compatible), a USB cable and a computer with the Arduino IDE; breadboard and jumper wires
  • Session 1: a small DC motor, TIP120, 1N4001 diode, 1 kΩ resistor, and 4 × AA alkaline cells (1.5 V each, about 6 V fresh) in a holder whose on/off switch is the power-off switch
  • TB6612FNG dual motor driver breakout
  • Two small 6 V DC gear motors (stall current within 1.0 A each), wheels and a castor; a wooden block with tape or clamps (sessions 2–3); a two-wheel chassis; cable ties
  • Motor battery: 4 × AA alkaline cells (1.5 V each, about 6 V fresh) in a holder whose on/off switch is the power-off switch. Not NiMH for the motors: 4 × 1.2 V is 4.8 V, and below 5 V the driver is rated 0.4 A per channel (5V>VM≥4.5V), not 1.0 A.
  • Tools: a screwdriver, flush-cut side-cutters, eye protection; low-temperature hot glue only if the chassis needs it
  • A digital multimeter; shared: a 6 × AA (alkaline or NiMH) holder with an on/off switch and a 2.1 mm centre-positive barrel plug for the board, kept by the adult

⚠ Safety before any session

  • Motors never run from a pin or the board's 5V pin: they run from their own battery, through a driver.
  • The motor battery has a power-off switch in the learner's reach; test it before every power-on.
  • To rewire: switch off and disconnect the motor battery first, then unplug USB. Never move a wire while powered.
  • Join every GND (board, driver, motor battery −). Keep the flyback diode in the transistor circuit.
  • Wheels off the table for the first test of every new sketch; then on the floor at the lowest value that starts both wheels, never above 160 of 255.
  • Lift the rover (wheels in the air) before switching the motor battery back on: the sketch keeps running on USB, so the wheels take its last command at once.
  • Chassis tools: screwdrivers pushed away from hands; side-cutters cut cable ties flush, eye protection on, sharp ends turned in; hot glue low-temperature or adult-only (it burns); soldering or drilling adult-only.
  • Motor battery: AA alkaline cells only; no NiMH, Li-ion, LiPo, RC packs or 18650 cells. Fingers and hair clear of wheels.
  • If anything gets warm: switch off or unplug at the holder, don't touch it, tell the adult.

Notes for the adult

  • Leads into the Rescue Rover course (R13-U4): this unit builds the rover of course sessions 7 and 8 in six sessions, on the studio's pins, with a power budget the course does not have.
  • The transistor circuit in session 1 is a bench basic: the rover itself uses the TB6612FNG, which drives two motors in both directions.
  • Each session lists a line to predict before power-on, a first check when it goes wrong, and a question to reflect on before tidying up.
  • Before the first upload, test an upload on each computer (Blink, with its own board and cable), so the session starts on time.
  • Alkaline cells rarely print a capacity, and it depends on the current drawn: give learners the mAh from the maker's datasheet at about their motors' running current.
  • Learners who already built a rover with a motor board (R11-U1) know the driver and the stop switch; here they wire and program it themselves. Readiness decides, not age.
  • Sign the session 6 demonstration only after seeing the learner run the pre-power check and drive without help.
  • The labs run a model of each sketch; only the real rover's behaviour counts as evidence here.

Planned studio features

Not built yet. The unit runs without them.

  • A chassis view: where the board, driver, battery and power-off switch sit on the rover, beside the breadboard layout.
  • A power-budget worksheet (loads, currents and where each came from, battery capacity, run time), kept in the browser only.
  • Notebook pages for unit plans (today the notebook holds only the Rescue Rover course).

Sources

The facts this plan relies on, in each source's own words.