Tutorial 2 - Hello LED
YouTube Video
Introduction
Turning an LED on and off is often called the “Hello World” of hardware programming. It’s the simplest way to test that your board is working and to learn the basics of controlling a digital output pin. Just like printing “Hello World” in software shows you the language syntax, blinking an LED introduces you to hardware timing and pin control.
With the ESP32-S3 Pico, we can start with a basic blink example and then expand into something more exciting—the classic Knight Rider effect, where multiple LEDs sweep back and forth in sequence. This builds directly on the first program and shows how simple concepts scale into more dynamic projects.
Turning LED On / Off
Components Needed
| Component | Quantity |
|---|---|
| ESP32S3 Pico | 1 |
| USB C Cable | 1 |
| Breadboard | 1 |
| Wires | Several |
| Resistor | 1 (330Ω) |
| LED | 1 |
Fritzing Diagram

Code
from machine import Pin
import utime
led = Pin(40, Pin.OUT)
while True:
led.value(1)
utime.sleep(2)
led.value(0)
utime.sleep(2)
Code Explanation
from machine import Pin
import utime
These lines import two MicroPython modules, Pin from the machine module and utime. The Pin class is used to represent a pin on the ESP32S3 Pico and utime provides functions for working with time.
led = Pin(40, Pin.OUT)
This line sets up a Pin object for pin 40 on the ESP32S3 Pico, and sets it to be an output pin (i.e., one that can be used to control a device like an LED). The Pin constructor takes two arguments: the pin number, and the mode (in this case, Pin.OUT).
while True:
led.value(1)
utime.sleep(2)
led.value(0)
utime.sleep(2)
This is the main loop of the program, which will run indefinitely (since True is always true). The loop consists of two steps:
- Turn the LED on by setting the value of the
ledpin to 1 (which will typically result in the LED being illuminated). - Wait for 2 seconds using the
utime.sleepfunction. - Turn the LED off by setting the value of the
ledpin to 0 (which will typically result in the LED being turned off). - Wait for another 2 seconds using the
utime.sleepfunction.
This loop will repeat indefinitely, resulting in the LED blinking on and off every 2 seconds.