TinySkiff ESP32-S3 Lab · Day 6 of 30

Ten lights
that flow

Today one light moves. You wire ten LED segments, each on its own pin, then upload a sketch that lights them one at a time down the bar and back — the first circuit where a list of pins and a single loop do the work of ten.

About 25 minutesArduino firstMicroPython optionalNo electronics assumed
Agent assist code TSK-DAY06-LEDBAR

Hand this to an agent so it can pull the lesson packet and coach you step by step.

01 First, know the pieces

What you need

Six things, and ten of one of them. Tap Define on any part you haven't met — the answer opens as a field note you can read and dismiss without losing your place.

Official manual photo of the ESP32-S3 development board.
Manual photo

ESP32-S3 board

The brain that runs your uploaded sketch.

Official manual image of the ESP32-S3 GPIO extension board.
Manual photo

GPIO extension board

Spreads the pins into rows you can reach and label.

Official manual photo of a ten-segment LED bar graph module.
Manual photo

LED bar graph

Ten small LEDs in one strip, each its own segment.

Official manual photo of a resistor with coloured value bands.
Manual photo

10 × 220 Ω resistors

One in series with each segment to keep every current gentle.

Official manual image of a jumper wire.
Manual photo

Jumper wires

Temporary, solder-free connections.

Official manual screenshot of the Arduino IDE interface.
Manual screenshot

Arduino IDE

Uploads the sketch to the board.

02 Make the physical circuit

Chart the circuit

The official Freenove diagram is your chart — schematic on top, the same circuit built on a breadboard below. Click it to enlarge. Ten segments look like a lot, but each one is the same small connection repeated.

Official Freenove circuit — C Tutorial, Chapter 3 (LED Bar), page 56.
10 bar segments (via 220 Ω each) GPIO 21 47 48 38 39 40 41 42 2 1 Each pin lights one segment of the bar.
Bar common row GND Returns every segment to zero volts.

The bar can go in backwards. The LED bar's label direction is easy to reverse. If the whole bar stays dark once you upload, rotate it 180° in the breadboard and try again. Unplug USB before you move any wire.

03 One action at a time

Build it

This is the main path — you can finish the day without opening a single field note. Tap each step as you go to keep your place.

0 / 7 done
  1. Seat the ESP32-S3 on the GPIO extension board and keep USB unplugged while you wire.

  2. Place the LED bar across the breadboard's centre channel so each segment has its own row.

  3. Wire each segment through its own 220 Ω resistor to its GPIO pin, working along the list in order.

  4. Wire the bar's common row to ground so every segment shares the same return.

  5. Compare every wire to the chart before you plug in USB.

  6. Open Sketch_03.1_FlowingLight.ino in Arduino IDE and upload it.

  7. Watch a single lit segment sweep along the bar and back.

Ten pins, one motion.

A list of pins and a loop are now driving the whole bar. Head to Test & debug to confirm the flowing sweep.

04 Read just enough code

Read the code

The sketch stays short even with ten LEDs, because the pins live in one list and a loop walks it. Switch to MicroPython if you'd rather see the same idea in Python — the wiring never changes.

Sketch_03.1_FlowingLight.ino
byte ledPins[] = {21, 47, 48, 38, 39, 40, 41, 42, 2, 1};
int ledCounts;

void setup() {
  ledCounts = sizeof(ledPins);
  for (int i = 0; i < ledCounts; i++) {
    pinMode(ledPins[i], OUTPUT);
  }
}

void loop() {
  for (int i = 0; i < ledCounts; i++) {       // forward sweep
    digitalWrite(ledPins[i], HIGH);
    delay(100);
    digitalWrite(ledPins[i], LOW);
  }
  for (int i = ledCounts - 1; i > -1; i--) {  // reverse sweep
    digitalWrite(ledPins[i], HIGH);
    delay(100);
    digitalWrite(ledPins[i], LOW);
  }
}
byte ledPins[] = {21, 47, 48, 38, 39, 40, 41, 42, 2, 1}One list holds all ten pins in bar order, so the loop can reach each by number.
digitalWrite(ledPins[i], HIGH)Lights whichever segment the loop is pointing at right now; the next line turns it off.
for (int i = ledCounts - 1; i > -1; i--)Walks the same list backwards, which is what sends the light flowing back the other way.

05 Understand, don't memorise

One list, one loop

There's no trick here — the loop just points at one pin after another and lights whatever it's pointing at, faster than the eye separates.

List

the pin array

All ten pins sit in one array in bar order.

Light

HIGH

The loop lights the pin it's pointing at right now.

Step

i++

It turns that one off and moves to the next pin.

Sweep

back again

A second loop walks the list in reverse so the light flows back.

The model one array of pins → walk it forward → walk it back → repeat

Why a pin array

Ten separate variables would mean ten copies of every line. One array lets a single loop stand in for all of them.

06 Know it worked

Test & debug

Nothing prints to the screen today — the proof is the moving light on the bar.

What you should see
LED bar
  • One lit segment starts at one end of the bar.
  • It travels along the bar a segment at a time to the far end.
  • Then it flows back the other way, and repeats for as long as the board has power.

Only one segment is lit at any instant — the flow is that single light moving, not a growing row.

If it doesn't
  • Whole bar stays dark? Rotate the LED bar 180° — its direction is easy to reverse — then re-check the common row to ground.
  • One segment never lights? Check that segment's own 220 Ω resistor and its jumper to its GPIO pin.
  • Nothing happens at all? Re-check the common row to ground, then that the sketch uploaded.
  • Upload fails? Swap in a data-capable USB cable.

07 Make the idea yours

Try this: bend the flow

Same working circuit, two small edits to the sketch. Both fit inside today's time and leave the wiring untouched.

Reverse the flow

Swap which loop runs first so the light starts its sweep from the other end. Predict which end it begins from before you upload.

Change the speed

Set every delay(100) to a larger or smaller number and upload. Find the speed where the flow still reads as a single moving light.

Logbook

08 Learn it with a hand on the tiller

Coach me through it

Every lesson ships with a code and a machine-readable packet, so an agent can guide you with full context.

Lesson code

TSK-DAY06-LEDBAR

How the agent should behave: guide one segment at a time, wait for you to confirm, explain terms on request, and always check wiring, board, port, and USB before changing code.

Field note

Shortcut

Prompt copied