pinGPT logo
Chapter C: Blink the LED4/4
Chapter B

Chapter C

Blink the Onboard LED

Your first real program. One LED, two lines of code, infinite excitement.

[ The onboard LED blinking on/off ]

1. Find the onboard LED

On the ESP32-S3 module there is a tiny LED soldered directly to the board. It is wired to GPIO 48. We don't need any wires — it's already connected.

2. Open your editor

Open Thonny (or your MicroPython editor) and make sure your pinGPT is selected as the interpreter. You should see a prompt that starts with >>>.

3. Type the blink program

Type this exactly into the editor:

from machine import Pin
from time import sleep

led = Pin(48, Pin.OUT)

while True:
    led.value(1)
    sleep(0.5)
    led.value(0)
    sleep(0.5)
[ Code editor showing the blink program ]

4. Run it

Press Run (or F5). The onboard LED should start blinking on and off every half second. Congratulations — you just wrote your first embedded program!

What just happened

You told the ESP32 to treat pin 48 as an output, then looped forever turning it on, waiting, off, waiting. That same pattern — output + loop + delay — is the foundation of almost every project you'll ever build.

Stop the program

Press Ctrl + C in the prompt to stop the loop. The LED will freeze in whichever state it was last in.