
Video
Circuit Diagram

Source Code
1// ─────────────────────────────────────────
2// BlueGrays · bluegrays.com
3// ESP32 Built-in LED Blink
4// ─────────────────────────────────────────
5// Blinks the built-in LED on the ESP32 DevKit V1 board every 1 s. No
6// external components are needed.
7//
8// Pins:
9// GPIO 2 -> Built-in LED (on the board)
10
11const int BUILTIN_LED_PIN = 2; // Built-in LED on the DevKit V1
12
13void setup() {
14 pinMode(BUILTIN_LED_PIN, OUTPUT);
15}
16
17void loop() {
18 digitalWrite(BUILTIN_LED_PIN, HIGH); // Turn the LED on
19 delay(1000); // Wait 1 s
20 digitalWrite(BUILTIN_LED_PIN, LOW); // Turn the LED off
21 delay(1000);
22}
23FAQ
Which pin is the internal LED connected to?▾
On the ESP32 DevKit V1, the built-in blue LED is connected to GPIO 2. On other boards (e.g., some ESP32-S3 boards), the built-in LED may be on a different pin or may be an addressable RGB LED; check your board's schematic.
Can I use the LED_BUILTIN constant?▾
Yes, if it's specified in the board definition. When "ESP32 Dev Module" is selected, LED_BUILTIN is usually 2; if you get a compilation error, set it directly to 2.
The internal LED isn't lit, but the code has been uploaded. Why?▾
Some inexpensive cards do not have built-in LEDs; they only have a power LED. Check to see if there are two small LEDs on the card; if not, try using an external LED.
Why should I do this project first?▾
It verifies code uploading, basic program execution, and the built-in LED output without needing any additional parts. It does not guarantee that the other GPIOs and all board functions work correctly.
