This project introduces basic digital output control by making an LED blink. Students will learn about GPIO pins and simple timing in MicroPython.
Connect the long leg (anode) of the LED to a digital GPIO pin on the ESP32 (e.g., GPIO16) through the resistor. Connect the short leg (cathode) of the LED to the GND pin on the ESP32. The resistor is crucial to limit the current flowing through the LED and prevent it from burning out.
The MicroPython code will initialize the chosen GPIO pin as an output. It will then enter a loop that repeatedly sets the pin high (turning the LED on), waits for a short duration, sets the pin low (turning the LED off), and waits again.
For this basic project, a web interface is not necessary.
# Project 1: LED Control and Blinking Patterns # This script demonstrates basic digital output control by making an LED blink. from machine import Pin # Import the Pin class to control GPIO pins import time # Import the time module for delays # Define the GPIO pin number connected to the LED. # Replace 16 with the actual GPIO pin you are using. led_pin = 16 # Create a Pin object for the LED pin and set it as an output. # Pin.OUT specifies that the pin will be used for outputting signals (high/low voltage). led = Pin(led_pin, Pin.OUT) # Define the blinking interval in seconds. # The LED will be on for this duration and off for this duration. blink_interval = 0.5 print("Starting LED blinking script...") # Start an infinite loop to make the LED blink continuously. while True: # Turn the LED on by setting the pin to a high logic level (typically 3.3V on ESP32). led.value(1) print("LED On") # Wait for the specified blink interval. time.sleep(blink_interval) # Turn the LED off by setting the pin to a low logic level (typically 0V). led.value(0) print("LED Off") # Wait for the specified blink interval. time.sleep(blink_interval) # This loop will run forever until the power is cut or the script is stopped.
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.