#106Beginner

ESP32 Built-in LED Blink

Blinking the built-in blue LED on the ESP32 DevKit V1. No external components required! The first project you should try when you buy an ESP32. GPIO 2 is connected to the built-in LED.

4.8(29)
53 completed
ESP32 Built-in LED Blink
If you have just got a new ESP32, this is the first thing to try: making the little blue light on the board turn on for a second and off for a second. You need no extra parts or wires, just plug the board into your computer. At a glance you know the board works and your program has been uploaded.

Video

Circuit Diagram

ESP32 Built-in LED Blink - Circuit

Source Code

Arduino (C++)
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}
23

FAQ

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.

ESP32 Built-in LED Blink | BlueGrays