In this project, students learn how to control one or more LEDs using an ESP32 microcontroller and MicroPython. They’ll experiment with turning LEDs on and off, controlling multiple LEDs in patterns, and adjusting blinking speeds. This introduces key concepts in hardware control, timing, and logic.
ESP32 GPIO23 —-> [220Ω] —-> |>| —-> GND
ESP32 GPIO22 —-> [220Ω] —-> |>| —-> GND
ESP32 GPIO21 —-> [220Ω] —-> |>| —-> GND
from machine import Pin
from time import sleep
# Define LED pins
led1 = Pin(23, Pin.OUT)
led2 = Pin(22, Pin.OUT)
led3 = Pin(21, Pin.OUT)
# Blink all LEDs in sequence
def blink_sequence():
for led in [led1, led2, led3]:
led.on()
sleep(0.3)
led.off()
sleep(0.3)
# Alternate LEDs
def alternate():
led1.on()
led2.off()
led3.on()
sleep(0.5)
led1.off()
led2.on()
led3.off()
sleep(0.5)
# Main loop
while True:
blink_sequence()
alternate()
You can explore a wide range of microcontroller and electronics projects, including Arduino, ESP32, IoT, and more. Each project comes with downloadable code, detailed guides, and the necessary hardware list.
You can explore a wide range of microcontroller and electronics projects, including Arduino, ESP32, IoT, and more. Each project comes with downloadable code, detailed guides, and the necessary hardware list.
You can explore a wide range of microcontroller and electronics projects, including Arduino, ESP32, IoT, and more. Each project comes with downloadable code, detailed guides, and the necessary hardware list.
You can explore a wide range of microcontroller and electronics projects, including Arduino, ESP32, IoT, and more. Each project comes with downloadable code, detailed guides, and the necessary hardware list.