Arduino Learning Studiorobotics pathway

R14-U4 · usually age 14 · Robotics Engineers

Precision Route Challenge

Can the robot navigate a prescribed course?

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

Build: Precision-navigation robot

A precision route to a written specification: the route, start, finish, tolerance, speed ceiling and trials fixed before any run; the rover's spin centre measured, distance per count, the coast after the brake and the quarter turn calibrated on the course floor; an error budget built from the learners' own measurements; the route run as states with the closed-loop drive; and five trials whose finishing error is reported against the specification and the budget.

  • Sense
  • Decide
  • Act
  • Test and debug

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

No studio lab or activity for this unit yet.

Sessions

  1. Session 1 · 75 min

    What exactly must the robot do?

    A specification: numbers that decide pass or fail, written before any run. The default one: route, 150 cm straight, a quarter turn right on the spot, 100 cm straight, then stop; start, the rover's front edge on the start line, its front-centre mark on the start cross; spin, the rover spins about the midpoint between its wheels, d cm behind its front-centre mark (measured by the learners), so the sketch drives 150 + d cm, turns, then drives 100 − d cm, and the front-centre mark follows the taped route; finish, the error is the distance from the finish cross to the rover's front-centre mark after it stops, measured with a tape; tolerance, agreed with the client and written down before any calibration; a group with no other figure uses 10 cm; pass, the five trials of session 5, run once each, every one finishing within the tolerance, with the sketch unchanged, no touching the rover during a run, and on the floor never above 160 of 255; a failed trial counts, and the streak is never restarted. A requirement that cannot be measured is not yet a specification.

    In the studio

    No studio lab: this session is off-screen.

    Hands-on

    With the adult as the client, read the default specification and agree the tolerance; write the whole specification on one page. Lay the route on the floor with masking tape, measure it twice with a tape measure, and mark the start and finish crosses. Draw the route to scale on squared paper with each length and the turn. Measure d, the distance from the rover's front-centre mark back to the midpoint between its two wheels, three times with a ruler, and draw why the sketch must drive 150 + d cm and then 100 − d cm (draw the rover at the corner: it spins about that midpoint, not about the mark). For each line of the specification, write how it will be measured and with what. Nothing is powered in this session.

    Evidence to collect

    The written specification (route lengths, turn, start, the spin centre and d, finish cross, tolerance, speed ceiling, trials, and how each is measured), the scale drawing with the rover at the corner, d measured three times, and the route measured twice on the floor.

    Predict
    Before any run, predict whether your rover can meet this tolerance, from your R14-U1 and R14-U2 errors.
    Debug
    If two people measure the route differently, agree how to hold the tape before going on.
    Reflect
    Which line of the specification will be hardest to meet, and why?

    Works towards: Meeting a specification

  2. Session 2 · 90 min

    How do we calibrate it?

    Calibration on the course floor, three trials each, the mean used and the spread kept for the budget: cm per count from each straight (the counts over the taped distance); the sideways drift at the end of each straight; the coast (counts after the brake command, as in R14-U1); and the counts for a quarter turn, first worked out from the track width (wheel centre to wheel centre): spinning on the spot, each wheel travels π × track width ÷ 4, one forward and one back, then corrected by trials. One encoder channel cannot tell direction: each wheel counts up whichever way it turns, so the sketch must know which way it commanded each wheel, and a count during the coast may be a wheel rolling back.

    In the studio

    No studio lab: this session is off-screen.

    Hands-on

    Start from your R14-U3 chosen version, saved as a new version for the course. Measure the motor battery 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). Open the Serial Monitor before the motor battery goes on (opening it restarts the UNO) and lift the rover, wheels in the air, for the first run. Then on the course floor, never above 160 of 255: with the stall rule in every driving state, drive the first straight (150 + d cm) and the second (100 − d cm) three times each, noting the counts, the distance, the sideways drift and the counts after each brake; then spin a quarter turn three times with your worked-out count and measure the angle against two taped lines at right angles, adjusting the count by the error. Save the calibrated numbers in a new version with its change note.

    Starting code: The learner's own sketch: the version chosen in R14-U3, saved as a new version for the course.

    Pins

    D2
    left wheel encoder SIG (photo interrupter breakout)
    D3
    right wheel encoder SIG (photo interrupter breakout)
    D4
    driver AIN1 (left motor)
    D5
    driver PWMA (left motor)
    D6
    driver PWMB (right motor)
    D7
    driver AIN2 (left motor)
    D8
    driver STBY moved from D3
    D9
    HC-SR04 Trig (wired, not read; kept OUTPUT and LOW)
    D10
    HC-SR04 Echo (wired, not read in these sketches)
    D11
    driver BIN2 (right motor)
    D12
    driver BIN1 (right motor)
    A0
    STOP button (other side to GND) moved from D2

    Evidence to collect

    A calibration table: each quantity (d, cm per count, drift on each straight, the coast after the brake, counts per quarter turn), three trials, the mean and the spread, and the version that holds the calibrated numbers.

    Predict
    Will the course floor give the same cm per count as R14-U1? Which way will it differ?
    Debug
    If the quarter turn varies a lot between trials, check the castor and the floor before changing the count.
    Reflect
    Which calibrated number are you least sure of, and how would more trials help?

    ⚠ Adult checks before power-on: Before every upload: setup() never sets pin 2 or 3 as OUTPUT (the encoders drive those pins). 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 battery reads at least 5.0 V before any run. Every value the controller can send passes through constrain(…, 0, 160): check that line before the upload. Lifted for the first run of every new sketch; on the floor never above 160 of 255, on a clear floor with the power-off switch in reach. The stall rule: in every driving state, go to STOPPED if a wheel's count is unchanged for 5 samples while its value is above its measured start value, or if the segment runs over twice its measured time. The USB cable is held clear of the wheels by the adult. Fingers and hair clear of wheels and discs while the motor battery is on. 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: Meeting a specification

  3. Session 3 · 80 min

    Where will the error come from?

    An error budget: every source of finishing error with a number from the learners' own measurements: each straight's distance spread, each straight's drift spread, the coast's spread, one count's step, the sideways miss at the finish that the turn's angle spread causes, and d: an error of e cm in d moves the finish by √2 × e. After the turn the directions swap: the first straight's length error ends as a sideways miss at the finish, and its drift as a length error. Worst cases are added, which gives an upper bound, not a prediction: errors at right angles combine to less than their sum, and they are rarely all at their worst at once. If the total is inside the tolerance the specification is likely met; if not, change one thing or report honestly that it cannot be met reliably. The finish cross is never moved.

    In the studio

    No studio lab: this session is off-screen.

    Hands-on

    From your calibration table and logs, list every error source with its number in cm. For the turn, draw the second straight on squared paper at the worst angle you measured and measure the miss at its end. For d, take your three measurements' spread as e and add √2 × e. Add the worst cases and compare the total with the tolerance. If it is bigger, choose one change (a lower speed, the coast subtracted from the count targets, more turn trials), predict its effect on the budget, save it as a new version, upload it, open the Serial Monitor before the motor battery goes on (opening it restarts the UNO), run it lifted once, and test that one segment three times on the course, never above 160 of 255, with the stall rule kept.

    Starting code: The learner's session 2 sketch (the calibrated version), with one change if the budget needs it.

    Pins

    D2
    left wheel encoder SIG (photo interrupter breakout)
    D3
    right wheel encoder SIG (photo interrupter breakout)
    D4
    driver AIN1 (left motor)
    D5
    driver PWMA (left motor)
    D6
    driver PWMB (right motor)
    D7
    driver AIN2 (left motor)
    D8
    driver STBY moved from D3
    D9
    HC-SR04 Trig (wired, not read; kept OUTPUT and LOW)
    D10
    HC-SR04 Echo (wired, not read in these sketches)
    D11
    driver BIN2 (right motor)
    D12
    driver BIN1 (right motor)
    A0
    STOP button (other side to GND) moved from D2

    Evidence to collect

    The error budget: each source (d included), where its number came from, the worst-case total as an upper bound against the tolerance, and the one change chosen (if any) with its predicted and measured effect.

    Predict
    Which single error source will be the biggest in your budget?
    Debug
    If a number in the budget has no measurement behind it, go back and measure it before adding it.
    Reflect
    Is the specification realistic for this rover? What evidence says so?

    ⚠ Adult checks before power-on: Before every upload: setup() never sets pin 2 or 3 as OUTPUT (the encoders drive those pins). 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. Every value the controller can send passes through constrain(…, 0, 160): check that line before the upload. Lifted for the first run of every new sketch; on the floor never above 160 of 255, on a clear floor with the power-off switch in reach. The stall rule: in every driving state, go to STOPPED if a wheel's count is unchanged for 5 samples while its value is above its measured start value, or if the segment runs over twice its measured time. The USB cable is held clear of the wheels by the adult. Fingers and hair clear of wheels and discs while the motor battery is on. 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: Meeting a specification

  4. Session 4 · 90 min

    Can the rover run the whole route?

    The route as states with switch...case: STRAIGHT1 (150 + d cm), TURN, STRAIGHT2 (100 − d cm) and STOPPED, each ending when its count target is reached (with the coast subtracted), the closed-loop drive in both straights, STOP on A0 checked first on every pass, and the stall rule in STRAIGHT1, TURN and STRAIGHT2, each with its own measured time. At each transition the counts are copied with interrupts off and each segment is measured from there. Dry runs, then full runs, one change at a time, each saved as a version.

    In the studio

    No studio lab: this session is off-screen.

    Hands-on

    Start from your session 3 version. Write the route as states, each with its count target and the stall rule, and print the state's name (and the stall rule's reason, if it fires) on every transition. Upload and open the Serial Monitor before the motor battery goes on (opening it restarts the UNO). Test the stall rule safely first: motor battery off, on USB only, start the drive: the counts stay at 0, so the rule must go to STOPPED within 5 samples, and the Serial Monitor must show it. Do it from each driving state. Then lift the rover, wheels in the air, switch the motor battery on, check each transition and press STOP in every state. Then on the course, never above 160 of 255, run the route three times; after each run, measure the finish error and, if needed, make one change, saved as a new version with its note.

    Starting code: The learner's session 3 sketch (its latest version), with the route written as states.

    Pins

    D2
    left wheel encoder SIG (photo interrupter breakout)
    D3
    right wheel encoder SIG (photo interrupter breakout)
    D4
    driver AIN1 (left motor)
    D5
    driver PWMA (left motor)
    D6
    driver PWMB (right motor)
    D7
    driver AIN2 (left motor)
    D8
    driver STBY moved from D3
    D9
    HC-SR04 Trig (wired, not read; kept OUTPUT and LOW)
    D10
    HC-SR04 Echo (wired, not read in these sketches)
    D11
    driver BIN2 (right motor)
    D12
    driver BIN1 (right motor)
    A0
    STOP button (other side to GND) moved from D2

    Evidence to collect

    The state diagram beside the sketch's cases, a transition test with STOP pressed in every state, the stall test from each driving state, and three practice runs with their finish errors and version notes.

    Predict
    Which transition is most likely to come early or late?
    Debug
    If the rover skips a segment, print the counts at each transition: was the target reached at once because the counts were not noted at the transition?
    Reflect
    Did a practice run show a problem that the error budget had missed?

    ⚠ Adult checks before power-on: Before every upload: setup() never sets pin 2 or 3 as OUTPUT (the encoders drive those pins). 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. Every value the controller can send passes through constrain(…, 0, 160): check that line before the upload. Lifted for the first run of every new sketch; on the floor never above 160 of 255, on a clear floor with the power-off switch in reach. The course is clear of people's feet. The stall rule: in every driving state, go to STOPPED if a wheel's count is unchanged for 5 samples while its value is above its measured start value, or if the segment runs over twice its measured time. The USB cable is held clear of the wheels by the adult. Fingers and hair clear of wheels and discs while the motor battery is on. 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: Meeting a specification

  5. Session 5 · 90 min

    Does it meet the specification?

    Five trials to the specification, with the sketch unchanged and the battery checked first: these five are the test, run once each, and a failed trial counts (no restarting the streak). Each trial's finish error is measured from the finish cross; the mean and spread are compared with the tolerance and with the error budget; pass or fail is stated with the numbers.

    In the studio

    No studio lab: this session is off-screen.

    Hands-on

    Start from your session 4 version and do not change it during the trials. Measure the motor battery 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). Open the Serial Monitor before the motor battery goes on (opening it restarts the UNO). Run five trials of the route on the course, never above 160 of 255, with the stall rule in every driving state, from the same start each time and without touching the rover during a run. Every trial counts: a failed one is reported, never rerun. After each, measure the distance from the finish cross to the front-centre mark and its direction, and save the log.

    Starting code: The learner's session 4 sketch, unchanged during the trials.

    Pins

    D2
    left wheel encoder SIG (photo interrupter breakout)
    D3
    right wheel encoder SIG (photo interrupter breakout)
    D4
    driver AIN1 (left motor)
    D5
    driver PWMA (left motor)
    D6
    driver PWMB (right motor)
    D7
    driver AIN2 (left motor)
    D8
    driver STBY moved from D3
    D9
    HC-SR04 Trig (wired, not read; kept OUTPUT and LOW)
    D10
    HC-SR04 Echo (wired, not read in these sketches)
    D11
    driver BIN2 (right motor)
    D12
    driver BIN1 (right motor)
    A0
    STOP button (other side to GND) moved from D2

    Evidence to collect

    The unit's evidence: complete a measured route with quantified error. A trial table of five runs (finish error in cm and its direction, inside the tolerance or not), the mean and spread, the comparison with the error budget, the logs, and a short report: did the rover meet the specification, and what was the largest error source?

    Predict
    Predict your mean finish error, from your error budget.
    Debug
    For a failed trial, read its log: which segment's counts or which transition went wrong?
    Reflect
    Did the error budget predict the trials well? What would you add to it next time?

    ⚠ Adult checks before power-on: Before every upload: setup() never sets pin 2 or 3 as OUTPUT (the encoders drive those pins). 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 battery reads at least 5.0 V before the trials. Every value the controller can send passes through constrain(…, 0, 160): check that line before the upload. Lifted for the first run of every new sketch; on the floor never above 160 of 255, on a clear floor with the power-off switch in reach. The course is clear of people's feet. The stall rule: in every driving state, go to STOPPED if a wheel's count is unchanged for 5 samples while its value is above its measured start value, or if the segment runs over twice its measured time. The USB cable is held clear of the wheels by the adult. Fingers and hair clear of wheels and discs while the motor battery is on. 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: Meeting a specification

Materials

  • The encoder rover from R14-U3, with its tuned controller (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)
  • Masking tape, a tape measure, a large protractor or two taped lines at right angles, squared paper
  • A digital multimeter
  • A computer with the Arduino IDE and a long USB cable for the tether

⚠ Safety before any session

  • Motors run from their own battery through the driver, never from a pin; every GND is joined.
  • To rewire: switch off and disconnect the motor battery first, then unplug USB. Never move a wire while powered.
  • Wheels lifted for the first run of every new version; then on the floor never above 160 of 255.
  • Every controller's output passes through constrain(…, 0, 160): no gain can drive a wheel above the floor ceiling.
  • 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.
  • The power-off switch on the motor battery is the stop that always works; STOP on A0 is extra. Test both before every floor run.
  • The course is clear of people's feet and anything fragile; no one touches the rover during a trial.
  • The stall rule: in every driving state, go to STOPPED if a wheel's count is unchanged for 5 samples while its value is above its measured start value, or if the segment runs over twice its measured time.
  • Fingers and hair clear of wheels and discs while the motor battery is on.
  • The USB cable is held clear of the wheels by the adult.
  • Motor battery: AA alkaline cells only; no NiMH, Li-ion, LiPo, RC packs or 18650 cells.
  • If anything gets warm: switch off or unplug at the holder, don't touch it, tell the adult.

Notes for the adult

  • Act as the client: agree the tolerance before session 2 and hold it. If the budget shows it cannot be met, the honest result is a report that says so with the numbers, not a moved finish cross.
  • The default route fits a classroom floor about 2 m by 2 m; change its lengths before session 1 if the room needs it, and never during the trials.
  • Adding worst cases gives an upper bound on the miss, not a prediction; most runs will do better. Ask learners to say which source their own data shows is largest.
  • The tape route is followed by the front-centre mark, but the rover spins about the midpoint between its wheels, d behind that mark: without the 150 + d and 100 − d targets every run misses by √2 × d, however good the rest is.
  • The five trials of session 5 are the test: if one fails, the result is reported as it is. Restarting a streak until five pass in a row is not allowed.
  • 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.
  • Learners who are ready can start here at any age once they can measure travel and its error, run a closed-loop drive and work from logged data (R14-U1 to U3).

Planned studio features

Not built yet. The unit runs without them.

  • A route and error-budget worksheet: the specification, each segment's measured spread and the worst-case total against the tolerance, kept in the browser only.
  • A trial log for unit plans (the notebook's trial log is only for the Rescue Rover course).

Sources

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