Blink the built-in LED on the ESP32-S3 WROOM. This is the “Hello World” of microcontroller programming.

No external circuit required — this project is powered over USB and uses the LED built into the ESP32-S3 WROOM board (connected internally to GPIO2).

File: 01_first_examples/code/Blink.py
from time import sleep_ms
from machine import Pin
led = Pin(2, Pin.OUT) # create LED object from pin2, Set Pin2 to output
while True:
led.value(1) # Turn LED On
sleep_ms(1000)
led.value(0) # Turn LED Off
sleep_ms(1000)
01_first_examples/code/.Blink.py to open it.If you disconnect the USB cable or press Reset, the code stops. Use offline mode to persist it.
In plain language the code:
sleep_ms and Pin used in this project# -- Setup --
# Import the functions `sleep_ms` and `Pin` used in this project
from time import sleep_ms
from machine import Pin
# Setup GPIO Pin 2 as output and assign it to the led variable
led = Pin(2, Pin.OUT)
# -- Program Loop --
# Loop forever
while True:
led.value(1) # Turn LED On
sleep_ms(1000) # Sleep for 1 second
led.value(0) # Turn LED Off
sleep_ms(1000) # Sleep for 1 second
DEFINITION - GPIO stands for **G**eneral **P**urpose **I**nput **O**utput. So this pin can either send out a signal, as in this case, or read in a signal, for example to read a button press.
Pin(id, mode) — creates a GPIO object. Pin.OUT sets it as an output.led.value(0/1) — sets the pin LOW (0) or HIGH (1).sleep_ms(ms) — pauses execution for the given number of milliseconds.while True — infinite loop; runs forever until interrupted.Try the following:
Adapted from Python_Tutorial.pdf Project 1.1