Blinking an LED with ESP32-S3
The ultimate starting point. Learn how to wire and control an external LED using Arduino IDE.
The Hardware Setup
Because the ESP32-S3 DevKitC-1 lacks a traditional built-in status LED on a standard GPIO, we will connect an external LED to GPIO 2. Always use a current-limiting resistor to protect your microcontroller pin from drawing too much current.
Figure 1: Connecting an external LED to GPIO 2 via a 220Ω resistor.
The Arduino Source Code
Copy and paste this code directly into your Arduino IDE. Make sure you have selected ESP32S3 Dev Module under your Tools > Board menu.
// ESP32-S3 LED Blink Tutorial - CircuitHub.pro
#include <Arduino.h>
// Define the pin connected to our LED
const int LED_PIN = 2;
void setup() {
// Initialize the GPIO pin as an output
pinMode(LED_PIN, OUTPUT);
}
void loop() {
// Turn the LED on (HIGH voltage level)
digitalWrite(LED_PIN, HIGH);
delay(1000); // Wait for 1 second (1000 milliseconds)
// Turn the LED off (LOW voltage level)
digitalWrite(LED_PIN, LOW);
delay(1000); // Wait for 1 second
}
Required Components
Need to grab the parts for this project? Here is exactly what was used in this guide. Click any item to view it on Amazon:
🚀 Take It Further: The SOS Challenge
Now that you can blink an LED, try modifying the delay() timings in the code to flash Morse code! Can you make the LED blink the international distress signal?
- S (Short): 3 quick blinks (200ms delay)
- O (Long): 3 long blinks (600ms delay)
- S (Short): 3 quick blinks (200ms delay)
Stuck? Check out our upcoming Intermediate Coding guides for the solution!