Skip to content
back to the classroom

From my Allegheny curriculum

Coding with Arduino

Middle & high school Two class periods★★★
An Arduino board wired on a breadboard

Supplies

  • 1 Arduino Uno (or equivalent) per student
  • Hookup wire, male to male
  • 470 ohm resistors (3 per student) and one 10k ohm resistor
  • 3 LEDs in fun colors
  • 1 RGB LED per student

About These Lessons

These are the coding lessons from the underwater robotics curriculum I wrote at Allegheny, where I taught Arduino to high school and middle school students as a Technical Leader. The sequence is four sketches, each one small enough to finish in class and each one visibly cooler than the last. That visible progress is the whole trick: kids stay hooked when every lesson ends with something new blinking at them.

The Four Sketch Sequence

  1. Blink: the built-in LED turns on and off. Hello, hardware.
  2. Blink 3: three LEDs on pins 13, 12, and 11 take turns. Now pins and wiring matter.
  3. RGB colors: one RGB LED cycles red, green, blue, white, purple. analogWrite enters the chat.
  4. The color fade: for loops smoothly fade the RGB LED through the whole spectrum.

The Payoff Sketch

Lesson three is where the magic lands. Three pins, one function, every color they can imagine:

void setColor(int redValue, int greenValue, int blueValue) {
  analogWrite(11, redValue);
  analogWrite(10, greenValue);
  analogWrite(9, blueValue);
}

void loop() {
  setColor(255, 0, 0);   // red
  delay(1000);
  setColor(170, 0, 255); // purple
  delay(1000);
}

Once students realize those three numbers are just a recipe, they start inventing their own colors immediately. Nobody has ever stopped at the colors on the slide.

Where It Leads

In the full course these sketches are the on-ramp to driving an underwater robot: the same pins and wires that blink an LED end up controlling motors through a waterproof tether. Blinking lights are never just blinking lights.