ESP32-S3 LED Blink - Micropython
This example blinks the on-board LED connected to GPIO 21 using MicroPython.
Hardware
| Item | Details |
|---|---|
| Board | Digicomp ESP32 S3 Dev Board |
| Microcontroller | ESP32-S3 |
| Programming language | MicroPython |
| On-board LED | GPIO 21 |
MicroPython Code
Save the following as main.py on the board:
from machine import Pin
from time import sleep
# On-board LED is connected to GPIO 21
led = Pin(21, Pin.OUT)
while True:
led.on()
sleep(1)
led.off()
sleep(1)How It Works
The program first imports Pin from the machine module and sleep from the time module.
from machine import Pin
from time import sleepGPIO 21 is configured as a digital output:
led = Pin(21, Pin.OUT)The while True loop then repeatedly turns the LED on and off:
led.on()
sleep(1)
led.off()
sleep(1)Each state lasts 1 second, producing a blink rate of approximately 0.5 Hz (one complete on/off cycle every 2 seconds).
Uploading to the Board
Install a suitable MicroPython firmware for the ESP32-S3.
Connect the Digicomp ESP32 S3 Dev Board to your computer using USB.
Open a MicroPython-compatible IDE or serial REPL, such as Thonny.
Make sure the board is running MicroPython.
Create a file named:
main.pyCopy the blink program into
main.py.Save
main.pyto the ESP32-S3 board.Reset the board.
The on-board LED connected to GPIO 21 should start blinking.
Expected Behavior
LED ON → 1 second
LED OFF → 1 second
LED ON → 1 second
LED OFF → 1 second
...