Learn Arduino UNO · Lesson 2

Build an 8 LED running-light sequence.

You already know how to control one LED. Now repeat that circuit eight times and make light move across the breadboard. This lesson reinforces digital outputs, timing and careful breadboard wiring before we add inputs.

35 minutes8 digital outputsSequencing

What you need

  • Arduino UNO
  • Breadboard
  • 8 LEDs
  • 8 × 220–330 Ω resistors
  • Jumper wires

Goal: illuminate one LED at a time from left to right, then make the sequence return back across the row.

▶ YOUTUBE DEMO PLACEHOLDERSuggested title: “Arduino 8 LED Chaser — Breadboard Wiring + Sequence Code”

Wire eight identical LED circuits

Keep all eight LEDs facing the same way. Each LED needs its own resistor. Connect the cathodes to the breadboard ground rail and link that rail to Arduino GND.

LED 1
Pin 2
LED 2
Pin 3
LED 3
Pin 4
LED 4
Pin 5
LED 5
Pin 6
LED 6
Pin 7
LED 7
Pin 8
LED 8
Pin 9

For each LED: Arduino pin → resistor → LED anode; LED cathode → GND.

Build with USB unplugged. Check every LED orientation and make sure no Arduino output pin is connected directly to GND.

Start with the deliberately obvious version

This code is repetitive on purpose. At Level 1, seeing every output instruction makes the sequence easy to follow. We deliberately bit-bash the outputs here rather than hiding the behaviour inside loops or arrays. Those techniques belong much later in Level S, after the hardware and basic logic are already second nature.

const int led1 = 2;
const int led2 = 3;
const int led3 = 4;
const int led4 = 5;
const int led5 = 6;
const int led6 = 7;
const int led7 = 8;
const int led8 = 9;

void setup() {
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);
  pinMode(led7, OUTPUT);
  pinMode(led8, OUTPUT);
}

void loop() {
  digitalWrite(led1, HIGH); delay(120); digitalWrite(led1, LOW);
  digitalWrite(led2, HIGH); delay(120); digitalWrite(led2, LOW);
  digitalWrite(led3, HIGH); delay(120); digitalWrite(led3, LOW);
  digitalWrite(led4, HIGH); delay(120); digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH); delay(120); digitalWrite(led5, LOW);
  digitalWrite(led6, HIGH); delay(120); digitalWrite(led6, LOW);
  digitalWrite(led7, HIGH); delay(120); digitalWrite(led7, LOW);
  digitalWrite(led8, HIGH); delay(120); digitalWrite(led8, LOW);

  digitalWrite(led7, HIGH); delay(120); digitalWrite(led7, LOW);
  digitalWrite(led6, HIGH); delay(120); digitalWrite(led6, LOW);
  digitalWrite(led5, HIGH); delay(120); digitalWrite(led5, LOW);
  digitalWrite(led4, HIGH); delay(120); digitalWrite(led4, LOW);
  digitalWrite(led3, HIGH); delay(120); digitalWrite(led3, LOW);
  digitalWrite(led2, HIGH); delay(120); digitalWrite(led2, LOW);
}

What changed from one LED?

The circuit principle has not changed at all: every output pin still goes HIGH or LOW. The only new idea is sequence. Each LED is switched on, held for 120 ms, then switched off before the next LED is activated. The repeated lines are intentionally visible so you can trace the pattern directly from code to hardware.

If the light appears to skip an LED, test that LED by temporarily replacing pulse(led1) with the suspect LED name and slowing the delay to 1000 ms.

Experiments

  1. Change 120 ms to 500 ms and watch the sequence become easier to inspect.
  2. Make the light travel left-to-right only.
  3. Make pairs of LEDs light at the same time.
  4. Create a centre-out pattern: LEDs 4 and 5, then 3 and 6, then 2 and 7, then 1 and 8.

Challenge

Create your own recognisable 8-LED pattern without changing the wiring. Try to make at least three different effects using only HIGH, LOW and delay.