{"id":7855,"date":"2026-05-03T21:07:22","date_gmt":"2026-05-03T21:07:22","guid":{"rendered":"https:\/\/hishamghanayem.com\/?p=7855"},"modified":"2026-05-10T17:57:13","modified_gmt":"2026-05-10T17:57:13","slug":"4-hours-10-leds-a-lot-of-patience","status":"publish","type":"post","link":"https:\/\/hishamghanayem.com\/en\/data-analysis\/data-storytelling\/4-hours-10-leds-a-lot-of-patience","title":{"rendered":"Video &#8211; 4 Hours, 10 LEDs &amp; A Lot of Patience"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"7855\" class=\"elementor elementor-7855\" data-elementor-post-type=\"post\">\n\t\t\t\t<div class=\"elementor-element elementor-element-65727c3 e-flex e-con-boxed e-con e-parent\" data-id=\"65727c3\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-7a03ffa elementor-widget elementor-widget-video\" data-id=\"7a03ffa\" data-element_type=\"widget\" data-e-type=\"widget\" data-settings=\"{&quot;youtube_url&quot;:&quot;https:\\\/\\\/www.youtube.com\\\/shorts\\\/UWIelIkqGqo&quot;,&quot;video_type&quot;:&quot;youtube&quot;,&quot;controls&quot;:&quot;yes&quot;}\" data-widget_type=\"video.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-wrapper elementor-open-inline\">\n\t\t\t<div class=\"elementor-video\"><\/div>\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-86e5f37 e-flex e-con-boxed e-con e-parent\" data-id=\"86e5f37\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-610bda9 elementor-widget elementor-widget-text-editor\" data-id=\"610bda9\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><em>How I built my first LED flowing light \u2014 and why I almost skipped the most important part.<\/em><\/p><h2>Where it started<\/h2><p>I am learning electronics and programming at the same time \u2014 two things that are already hard on their own. So when I reached <strong>Chapter 3 of the ESP32-S3 starter kit<\/strong>, the LED Bar project, I thought: &#8220;This looks simple enough. Ten LEDs lighting up in sequence. How hard can it be?&#8221;<\/p><p>The answer, it turns out, was: <strong>four hours hard.<\/strong><\/p><blockquote><p>&#8220;I almost skipped the testing part. I almost just uploaded the code and called it done. That would have been my biggest mistake.&#8221;<\/p><\/blockquote><p>This post is my honest story of what happened, what I built, and what I learned \u2014 not just about circuits, but about the mindset you need when you are learning something new.<\/p><h2>What the project is supposed to do<\/h2><p>The goal is a <strong>&#8220;flowing light&#8221;<\/strong> \u2014 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.<\/p><p>The ten LEDs connect to GPIO pins <code>21, 47, 48, 38, 39, 40, 41, 42, 2, 1<\/code> on the board. Each LED needs its own 220\u03a9 resistor so it doesn&#8217;t burn out. Ten LEDs, ten resistors, ten wires \u2014 and everything has to be in the right place for the circuit to work.<\/p><h2>My honest timeline<\/h2><p><strong>Hour 1:<\/strong> Read the documentation, set up the breadboard, and felt confident. &#8220;This is going well,&#8221; I thought. I had the wiring done and uploaded the code.<\/p><p><strong>Hours 1\u20132:<\/strong> Nothing worked. One LED didn&#8217;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.<\/p><p><strong>Hours 2\u20133:<\/strong> 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.<\/p><p><strong>Hours 3\u20134:<\/strong> Ran the code again. Eight LEDs working. Then nine. Then \u2014 finally \u2014 all ten lit up in a perfect flowing wave. Honestly, I almost cried a little. Worth it.<\/p><blockquote><p>There was a point where I thought: &#8220;the code is correct, the documentation says this should work, maybe my board is broken.&#8221; I was ready to move on and pretend this chapter didn&#8217;t happen. I&#8217;m really glad I didn&#8217;t.<\/p><\/blockquote><h2>The code \u2014 explained line by line<\/h2><p>I want to share the code here with full comments, because I am learning \u2014 and maybe you are too. Understanding <em>why<\/em> each line exists is more important than just copying and pasting.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-15b3533 e-flex e-con-boxed e-con e-parent\" data-id=\"15b3533\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-1d54053 elementor-widget elementor-widget-code-highlight\" data-id=\"1d54053\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-javascript line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-javascript\">\n\t\t\t\t\t<xmp><pre><code>\nimport time               # We need 'time' so we can add pauses (delays) in our program\nfrom machine import Pin   # 'Pin' lets us control the physical GPIO pins on the ESP32\n\n# This list holds the GPIO pin numbers connected to our 10 LEDs.\n# The order matters: index 0 is the first LED, index 9 is the last.\n# These numbers come from how I physically wired the board.\npins = [21, 47, 48, 38, 39, 40, 41, 42, 2, 1]\n\ndef showled():\n    # How many LEDs do we have? len() counts the items in our list.\n    # Storing it in a variable avoids calling len() again and again.\n    length = len(pins)\n\n    # --- FORWARD SWEEP: light up LEDs from left to right ---\n    for i in range(0, length):        # i goes 0, 1, 2 ... 9\n        led = Pin(pins[i], Pin.OUT)   # Create a Pin object for this LED, set it as OUTPUT\n        led.value(1)                  # Turn the LED ON (value 1 = HIGH = voltage applied)\n        time.sleep_ms(100)            # Wait 100 milliseconds so we can actually see it lit up\n        led.value(0)                  # Turn the LED OFF (value 0 = LOW = no voltage)\n\n    # --- REVERSE SWEEP: light up LEDs from right to left ---\n    for i in range(0, length):             # i still goes 0 to 9 ...\n        led = Pin(pins[(length - i - 1)], Pin.OUT)\n        # ... but (length - i - 1) = (10 - i - 1) counts BACKWARDS: 9, 8, 7 ... 0\n        # So we are picking pins from the END of the list first this time\n        led.value(1)                       # Turn LED ON\n        time.sleep_ms(100)                 # Wait 100ms\n        led.value(0)                       # Turn LED OFF\n\n# --- MAIN LOOP ---\n# 'while True' runs forever (until we unplug the board or reset it).\n# It calls showled() over and over, creating the endless flowing wave effect.\nwhile True:\n    showled()\n<\/code><\/pre><\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-0ae8788 e-flex e-con-boxed e-con e-parent\" data-id=\"0ae8788\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-40be44c elementor-widget elementor-widget-text-editor\" data-id=\"40be44c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\n<h2>The lessons I&#8217;ll carry forever<\/h2>\n<ol>\n \t<li><strong>Never skip testing.<\/strong> I was so tempted to call it &#8220;done&#8221; after uploading the code. But the circuit is physical \u2014 one loose wire kills everything. Test each LED individually before running the full program.<\/li>\n \t<li><strong>Calm beats speed.<\/strong> Every time I panicked and rushed, I made new mistakes. When I slowed down and tested methodically \u2014 one connection at a time \u2014 I actually moved faster.<\/li>\n \t<li><strong>Frustration is part of the process.<\/strong> Four hours on ten LEDs sounds embarrassing. But those four hours taught me more than four minutes of it working would have. The struggle <em>is<\/em> the lesson.<\/li>\n \t<li><strong>Understand the math, not just the code.<\/strong> The reverse-loop formula <code>(length - i - 1)<\/code> looks weird until you trace it by hand. Always trace through the logic manually at least once.<\/li>\n \t<li><strong>Small wins matter.<\/strong> When the 8th LED finally lit up after hours of debugging, that felt incredible. Celebrate every small moment \u2014 it keeps you going.<\/li>\n<\/ol>\n<h2>What&#8217;s next<\/h2>\nChapter 4 covers <strong>Analog signals and PWM<\/strong> \u2014 which means I&#8217;ll be controlling the <em>brightness<\/em> of LEDs, not just on\/off. I&#8217;m excited and also already a little nervous. But after this project, I know I can handle it.\n\nI&#8217;m sharing all of this publicly because I think it&#8217;s important to show that learning is messy. It doesn&#8217;t always look like a clean tutorial. Sometimes it looks like four hours and ten LEDs and a lot of deep breaths.\n\nIf you&#8217;re learning too \u2014 keep going. \ud83d\ude4c\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>https:\/\/www.youtube.com\/shorts\/UWIelIkqGqo How I built my first LED flowing light \u2014 and why I almost skipped the most important part. Where it started I am learning electronics and programming at the same time \u2014 two things that are already hard on their own. So when I reached Chapter 3 of the ESP32-S3 starter kit, the LED [&hellip;]<\/p>","protected":false},"author":1,"featured_media":7856,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"postBodyCss":"","postBodyMargin":[],"postBodyPadding":[],"postBodyBackground":{"backgroundType":"classic","gradient":""},"footnotes":""},"categories":[70,10],"tags":[],"class_list":["post-7855","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-case-study","category-data-storytelling"],"_links":{"self":[{"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/posts\/7855","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/comments?post=7855"}],"version-history":[{"count":11,"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/posts\/7855\/revisions"}],"predecessor-version":[{"id":7870,"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/posts\/7855\/revisions\/7870"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/media\/7856"}],"wp:attachment":[{"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/media?parent=7855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/categories?post=7855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hishamghanayem.com\/en\/wp-json\/wp\/v2\/tags?post=7855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}