Arduino Learning Studiorobotics pathway

R12-U2 · usually age 12 · Robotics Engineers

Arduino as a Controller

How does an Arduino program interact with hardware?

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

Build: Programmable LED and button

The Arduino as a controller: a sketch's setup() and loop(), digital outputs and inputs with INPUT_PULLUP, keeping time with millis() instead of waiting, and the Serial Monitor to see what the program is doing. Learners change sketches on purpose and explain each change.

  • Sense
  • Decide
  • Act

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

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 · 75 min

    What does a sketch do once, and what does it repeat?

    setup() runs once after power-up or reset; loop() repeats. Variables. Serial.begin() and Serial.println(), and a Serial Monitor set to the same baud rate.

    In the studio

    Hands-on

    In Meet the board, predict and then watch the model of setup() once and loop() repeating. On the real board, start from Bare Minimum: print a greeting in setup() and a count in loop(), upload, and watch how fast the lines arrive. Press RESET and note what you see. Then move the count's declaration inside loop(): predict first, then test.

    Starting code: Bare Minimum, from File/Examples/01.Basics/BareMinimum: an empty setup() and loop().

    Evidence to collect

    A prediction and the real Serial Monitor lines, annotated: which line ran once, which repeated, and why the count inside loop() never grows.

    Predict
    Before uploading, write which line you expect to see once and which many times.
    Debug
    If the Serial Monitor shows nothing or garbled text, check its baud rate against Serial.begin() before changing the code.
    Reflect
    In your own words: what does the board do between two runs of loop()?

    ⚠ Adult checks before power-on: The board sits on a non-conductive surface; nothing is wired to D0 or D1, which carry the USB serial link; the Serial Monitor uses the baud rate in Serial.begin().

    Works towards: Reading code, Serial debugging

  2. Session 2 · 75 min

    How does the board switch an output?

    pinMode(pin, OUTPUT), digitalWrite() HIGH (5 V) and LOW (0 V), and delay().

    In the studio

    Hands-on

    In Blink, predict a pattern from two delay() values, then test. On the bench, with USB unplugged, move the LED from D13 to D8 and change the sketch to match: both the wire and the code must change. With a long on-time, measure the D8 jumper's breadboard row to the GND rail on DC volts, when HIGH and when LOW. Then, with USB unplugged, add a second LED on D7 and make the two take turns.

    Starting code: Blink, from File/Examples/01.Basics/Blink, with LED_BUILTIN replaced by the pin you wire.

    Pins

    D13
    LED 1 (Blink's pin, before the move)
    D8
    LED 1, moved
    D7
    LED 2

    Evidence to collect

    The changed sketch with each changed line explained in the learner's words, and the measured HIGH and LOW voltages.

    Predict
    Before each upload, write the pattern you expect from the two delay() values.
    Debug
    If the moved LED stays dark, check whether the wire and the sketch name the same pin before touching anything else.
    Reflect
    Which change needed both the wire and the code, and how will you remember that?

    ⚠ Adult checks before power-on: USB unplugged while moving wires; each LED has its own 220 Ω resistor in series and its short leg to GND. For the volts readings: red lead in the V/Ω socket, never 10A; probes go on breadboard rows or rails, not at the header pins.

    Works towards: Inputs and outputs in code, Reading code

  3. Session 3 · 90 min

    How does the board read a button?

    digitalRead(); INPUT_PULLUP and active-low (pressed reads LOW); a floating input with no pull-up.

    In the studio

    Hands-on

    In Push a button, predict the reading for pressed and released, then test. On the bench, with USB unplugged, wire the button across the breadboard's gap from D2 to GND. Print digitalRead(2) to the Serial Monitor with INPUT_PULLUP, pressed and released. Then change the mode to INPUT, with the button released, and watch what the reading does. Change it back.

    Starting code: InputPullupSerial, from File/Examples/02.Digital/InputPullupSerial: it reads pin 2 with INPUT_PULLUP and prints it.

    Pins

    D2
    push button (other side to GND)

    Evidence to collect

    An input state table: mode × button → reading, with the INPUT case marked unreliable and the reason given.

    Predict
    Predict the reading for pressed and released before you press anything.
    Debug
    If the reading never changes, check that the button's two legs in use are diagonally opposite, then the D2 jumper's row.
    Reflect
    Why is a reading you cannot trust worse than no reading at all?

    ⚠ Adult checks before power-on: USB unplugged while wiring; the button goes between the pin and GND, never straight across 5V and GND; diagonally opposite legs are used.

    Works towards: Inputs and outputs in code, Serial debugging

  4. Session 4 · 90 min

    Can the controller blink and listen at the same time?

    Why delay() makes a program miss a button press, and keeping time with millis() so loop() never stops.

    Hands-on

    With USB unplugged, build one LED on D8 blinking slowly and a button on D2 that lights a second LED on D7. First use delay(1000) for the blink: press the button ten times quickly and count how many the second LED shows. Then rewrite the blink with millis(): note the time of the last change, and toggle only when enough time has passed. Run the same ten presses.

    Starting code: The learner's sketches from sessions 2 and 3, combined; for the millis() version, compare with Blink Without Delay (File/Examples/02.Digital/BlinkWithoutDelay).

    Pins

    D8
    blinking LED
    D2
    push button
    D7
    second LED

    Evidence to collect

    A before/after table (presses noticed out of ten, with delay() and with millis()) and a sentence on why delay() misses presses.

    Predict
    Predict how many of ten quick presses the delay() version will notice.
    Debug
    If the millis() version never blinks, print the time and the last change to the Serial Monitor and compare them.
    Reflect
    Where else would a program that waits miss something important?

    ⚠ Adult checks before power-on: Each LED has its resistor; the button is between D2 and GND; USB unplugged while adding the second LED.

    Works towards: Timing without waiting, Inputs and outputs in code

  5. Session 5 · 90 min

    Can I change a sketch on purpose, not by luck?

    A latching stop button: each press flips the LED once. Edge detection, a debounce time with millis(), and Serial prints as a debugging tool.

    In the studio

    Hands-on

    Start from Debounce and change it on purpose: it expects a button to 5V with a resistor to GND, but yours goes from D2 to GND, so use INPUT_PULLUP and make a press mean LOW, and point its LED at your LED on D8. Write the plan as comments first: what to remember, when a press counts, what to print. Change one thing at a time and test after each. When a press flips the LED twice, print the reading and the time to the Serial Monitor to see why, then tune the debounce time. Finally, explain one line the adult points to.

    Starting code: Debounce, from File/Examples/02.Digital/Debounce (not a blank page); the learner adapts it to their own circuit.

    Pins

    D2
    push button
    D8
    LED

    Evidence to collect

    The unit's evidence: the modified Debounce sketch, not copying blindly: every change explained in the learner's own words, the Serial lines that showed the bug, and an explanation of a line chosen by the adult.

    Predict
    Before changing anything, predict what Debounce will do with your button wired to GND.
    Debug
    When one press counts twice, print the reading and millis() for each change and find the bounce in the Serial lines.
    Reflect
    Which of your changes would you explain first to someone copying your sketch?

    ⚠ Adult checks before power-on: The button is between D2 and GND; the LED has its resistor; USB unplugged while rewiring.

    Works towards: Timing without waiting, Reading code, Serial debugging

Materials

  • Per pair: Arduino Uno R3 (or compatible), its USB cable, and a computer with the Arduino IDE
  • Breadboard, jumper wires, two 5 mm LEDs, two 220 Ω resistors, a 4-leg push button
  • A digital multimeter (DC volts)

⚠ Safety before any session

  • Unplug USB before changing a wire.
  • Every LED has its resistor; a button goes between a pin and GND, never across 5V and GND.
  • Keep D0 and D1 free: on the Uno they are the serial pins used by USB.

Notes for the adult

  • Before the first upload, test an upload on each computer (Blink, with its own board and cable), so the session starts on time.
  • The aim is changing code on purpose: ask for a prediction before every upload, and for the reason behind every change.
  • A learner who already writes setup() and loop() fluently can move on to R12-U3; readiness decides, not age.
  • The labs run a model of each sketch; only the real board's behaviour counts as evidence here.

Planned studio features

Not built yet. The unit runs without them.

  • A side-by-side view of the learner's own sketch and its Serial lines for the notebook (no upload of code: kept in the browser).
  • 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.