Question Details

No question body available.

Tags

c embedded esp32

Answers (1)

Accepted Answer Available
Accepted Answer
May 19, 2026 Score: 3 Rep: 577 Quality: High Completeness: 50%

It seems that your original code is already correct. Not every ESP32 development board has an onboard LED connected to GPIO 2. First, you should check whether the LED on your development board is actually connected to GPIO 2 or to another GPIO pin.

If the LED is connected to a different pin, you can simply update the GPIO number in your original code and run it again.

In your updated code, you included the built-in printf() function. This function works with the ESP32 serial interface, and some development boards include serial debugging LEDs. Because of this, you might think the code is working correctly since the LED blinks when printf() is used, but that is not necessarily the case.

My advice is to first check your development board and identify the correct GPIO pin connected to the onboard LED.