How I built my first LED flowing light β and why I almost skipped the most important part.
Where it started
I am learning electronics and programming at the same time β two things that are already hard on their own. So when I reached Chapter 3 of the ESP32-S3 starter kit, the LED Bar project, I thought: “This looks simple enough. Ten LEDs lighting up in sequence. How hard can it be?”
The answer, it turns out, was: four hours hard.
“I almost skipped the testing part. I almost just uploaded the code and called it done. That would have been my biggest mistake.”
This post is my honest story of what happened, what I built, and what I learned β not just about circuits, but about the mindset you need when you are learning something new.
What the project is supposed to do
The goal is a “flowing light” β ten LEDs on a bar graph component connected to the ESP32-S3 microcontroller. The lights are supposed to turn on one by one from left to right, then go back from right to left, over and over, like a wave. It looks beautiful when it works.
The ten LEDs connect to GPIO pins 21, 47, 48, 38, 39, 40, 41, 42, 2, 1 on the board. Each LED needs its own 220Ξ© resistor so it doesn’t burn out. Ten LEDs, ten resistors, ten wires β and everything has to be in the right place for the circuit to work.
My honest timeline
Hour 1: Read the documentation, set up the breadboard, and felt confident. “This is going well,” I thought. I had the wiring done and uploaded the code.
Hours 1β2: Nothing worked. One LED didn’t light up at all. Another flickered. I wanted to stop and move on to the next chapter. The temptation to skip was very real.
Hours 2β3: I made myself calm down. I tested each LED individually by touching a wire to power. I found two loose connections and one resistor in the wrong row. I fixed them one by one.
Hours 3β4: Ran the code again. Eight LEDs working. Then nine. Then β finally β all ten lit up in a perfect flowing wave. Honestly, I almost cried a little. Worth it.
There was a point where I thought: “the code is correct, the documentation says this should work, maybe my board is broken.” I was ready to move on and pretend this chapter didn’t happen. I’m really glad I didn’t.
The code β explained line by line
I want to share the code here with full comments, because I am learning β and maybe you are too. Understanding why each line exists is more important than just copying and pasting.
import time # We need 'time' so we can add pauses (delays) in our program
from machine import Pin # 'Pin' lets us control the physical GPIO pins on the ESP32
# This list holds the GPIO pin numbers connected to our 10 LEDs.
# The order matters: index 0 is the first LED, index 9 is the last.
# These numbers come from how I physically wired the board.
pins = [21, 47, 48, 38, 39, 40, 41, 42, 2, 1]
def showled():
# How many LEDs do we have? len() counts the items in our list.
# Storing it in a variable avoids calling len() again and again.
length = len(pins)
# --- FORWARD SWEEP: light up LEDs from left to right ---
for i in range(0, length): # i goes 0, 1, 2 ... 9
led = Pin(pins[i], Pin.OUT) # Create a Pin object for this LED, set it as OUTPUT
led.value(1) # Turn the LED ON (value 1 = HIGH = voltage applied)
time.sleep_ms(100) # Wait 100 milliseconds so we can actually see it lit up
led.value(0) # Turn the LED OFF (value 0 = LOW = no voltage)
# --- REVERSE SWEEP: light up LEDs from right to left ---
for i in range(0, length): # i still goes 0 to 9 ...
led = Pin(pins[(length - i - 1)], Pin.OUT)
# ... but (length - i - 1) = (10 - i - 1) counts BACKWARDS: 9, 8, 7 ... 0
# So we are picking pins from the END of the list first this time
led.value(1) # Turn LED ON
time.sleep_ms(100) # Wait 100ms
led.value(0) # Turn LED OFF
# --- MAIN LOOP ---
# 'while True' runs forever (until we unplug the board or reset it).
# It calls showled() over and over, creating the endless flowing wave effect.
while True:
showled()
The lessons I’ll carry forever
- Never skip testing. I was so tempted to call it “done” after uploading the code. But the circuit is physical β one loose wire kills everything. Test each LED individually before running the full program.
- Calm beats speed. Every time I panicked and rushed, I made new mistakes. When I slowed down and tested methodically β one connection at a time β I actually moved faster.
- Frustration is part of the process. Four hours on ten LEDs sounds embarrassing. But those four hours taught me more than four minutes of it working would have. The struggle is the lesson.
- Understand the math, not just the code. The reverse-loop formula
(length - i - 1)looks weird until you trace it by hand. Always trace through the logic manually at least once. - Small wins matter. When the 8th LED finally lit up after hours of debugging, that felt incredible. Celebrate every small moment β it keeps you going.


