TinySkiff ESP32-S3 Lab · Day 20 of 30

Eight lights
from three wires

Today a chip joins the crew. You feed a 74HC595 one byte over three wires — data, clock, latch — and it fans those eight bits out to the LED bar all at once. The flowing light you built on Day 6 took ten GPIOs; today's takes three.

About 30 minutesArduino firstMicroPython optionalThe LED bar returns
Agent assist code TSK-DAY20-SHIFTREG

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, one of them a chip with sixteen legs. 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 illustration of the 74HC595 shift register chip with its sixteen pins numbered.
Manual illustration

74HC595 shift register

The chip that turns three wires into eight outputs.

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

LED bar graph

The bar from Day 6 — eight of its segments light today.

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

8 × 220 Ω resistors

One per segment to keep each LED's current gentle.

Official manual image of a jumper wire.
Manual photo

Jumper wires (about 15)

Temporary, solder-free connections — the most you've used so far.

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. The chip sits across the breadboard's centre channel, and each connection tells you where the wire goes and why.

Official Freenove circuit — C Tutorial, Chapter 14 (74HC595 & LED Bar Graph), page 133.
GPIO 12 74HC595 DS (pin 14) Carries the byte into the chip one bit at a time.
GPIO 13 74HC595 ST_CP latch (pin 12) One rising edge here presents all eight stored bits at once.
GPIO 14 74HC595 SH_CP clock (pin 11) Each tick tells the chip to take in the next bit.
Outputs Q0–Q7 LED bar via 220 Ω each Eight chip outputs each drive one segment through its own resistor.
OE (chip pin 13) GND Held low so the outputs stay switched on.
MR (chip pin 10) 5V Held high so the chip never clears what it holds.

Mind the chip's notch. The 74HC595 only works one way round — the half-moon notch at one end marks where pin 1 sits, and it must match the chart. 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 / 9 done
  1. Seat the ESP32-S3 on the GPIO extension board and keep USB unplugged while you wire.

  2. Straddle the 74HC595 across the breadboard's centre channel with its notch matching the chart.

  3. Give the chip power — VCC and MR (pin 10) to 5V, GND and OE (pin 13) to ground.

  4. Run the three control wires — GPIO 12 to DS (pin 14), GPIO 13 to ST_CP (pin 12), GPIO 14 to SH_CP (pin 11).

  5. Connect outputs Q0–Q7 to the LED bar, with a 220 Ω resistor in series for each segment.

  6. Check the LED bar's direction against the chart — you saw on Day 6 how easily it reverses.

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

  8. Open Sketch_14.1_FlowingLight02.ino in Arduino IDE and upload it.

  9. Watch one lit LED run along the bar and back.

Three wires carry a byte.

The chip is holding eight lights for you. Head to Test & debug to confirm the flow.

04 Read just enough code

Read the code

The sketch keeps one byte, x, and lets its single 1 bit slide left and then right. A small helper, writeTo595, hands each new byte to the chip and latches it onto the outputs. Switch to MicroPython if you'd rather see the same idea in Python — the wiring never changes.

Sketch_14.1_FlowingLight02.ino
int latchPin = 13;          // Pin connected to ST_CP of 74HC595(Pin12)
int clockPin = 14;          // Pin connected to SH_CP of 74HC595(Pin11)
int dataPin = 12;           // Pin connected to DS of 74HC595(Pin14)

void setup() {
  // set pins to output
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop() {
  byte x = 0x01;    // 0b 0000 0001
  for (int j = 0; j < 8; j++) { // Let led light up from right to left
    writeTo595(LSBFIRST, x);
    x <<= 1;
    delay(50);
  }
  delay(100);
  x = 0x80;       //0b 1000 0000
  for (int j = 0; j < 8; j++) { // Let led light up from left to right
    writeTo595(LSBFIRST, x);
    x >>= 1;
    delay(50);
  }
  delay(100);
}
void writeTo595(int order, byte _data ) {
  // Output low level to latchPin
  digitalWrite(latchPin, LOW);
  // Send serial data to 74HC595
  shiftOut(dataPin, clockPin, order, _data);
  // Output high level to latchPin, and 74HC595 will update the data to the parallel output port.
  digitalWrite(latchPin, HIGH);
}
shiftOut(dataPin, clockPin, order, _data)Sends the byte to the chip one bit at a time — data on GPIO 12, a clock tick on GPIO 14 for each bit.
digitalWrite(latchPin, HIGH)The rising edge on GPIO 13 moves all eight stored bits to the outputs in one step.
x <<= 1Slides the single 1 bit one place left, so the lit LED takes one step along the bar; delay(50) sets the pace.

05 Understand, don't memorise

Three wires carry a byte

The chip is a small memory with eight outputs. Watch what the three wires each do, and the moving light explains itself.

Load

Bit by bit

Each clock tick pushes the next bit of the byte into the chip.

Latch

One edge

A rising edge on the latch pin presents all eight bits at once.

Light

Eight outputs

Q0 through Q7 each drive one segment of the bar.

Shift

The byte moves

x <<= 1 slides the lit bit along and the light follows it.

The model eight outputs = one byte carried over three wires

Where Day 6's ten pins went

Day 6 gave every segment its own GPIO in a pin array. Today the chip holds all eight states, and the board keeps just three wires — data, clock, and latch.

What the latch is for

While bits are still arriving, the outputs hold their previous pattern. The latch edge updates them all in one clean step, so you never see half a byte on the bar.

06 Know it worked

Test & debug

Nothing prints to the screen today — the proof is the light running along the bar in front of you.

What you should see
LED bar
  • One lit LED runs along the bar to one end.
  • It turns and runs back to where it started.
  • The run repeats forever, with a brief pause at each end.

Eight segments take part — the chip has eight outputs, so two segments of the ten-segment bar stay dark. That's correct.

If it doesn't
  • Nothing lights at all? Check the chip's orientation by its notch, then its power — VCC and MR to 5V, GND and OE to ground.
  • Pattern scrambled or jumpy? Re-check the three control wires — DS on GPIO 12, latch on GPIO 13, clock on GPIO 14.
  • One LED never lights? Check that segment's 220 Ω resistor and the bar's direction, just as on Day 6.
  • Upload fails? Swap in a data-capable USB cable.

07 Make the idea yours

Try this: reshape the byte

Same working circuit, one variable to play with: the byte x. Everything the bar does comes from how you shape and shift it. It fits inside today's 30 minutes.

Change the pace

Change both delay(50) lines together — try 20 for a sprint, 150 for a stroll — and upload until the flow feels right.

Run a pair

Start the first loop with x = 0x03 so two neighbouring LEDs travel together. Predict what the second loop's starting value needs to be before you change it.

Fill the bar

In the first loop, replace x <<= 1 with x = (x << 1) | 1 so each step keeps every light already lit and the bar fills from one end.

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-DAY20-SHIFTREG

How the agent should behave: guide one physical connection 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