In this blog, we’ll be taking a step-by-step look at how to turn on an LED with the ESP32 development board. The ESP32 development board is a low-cost, low-power board that comes with the ESP32 microcontroller pre-installed, making it easier for developers to get started with the ESP32.
Materials and Tools:
- ESP32
- LED (Light-Emitting Diode)
- Breadboard
- Jumper wires
Step 1: Setting Up the ESP32 Development Board
Before we can start turning on an LED, we need to set up the ESP32 development board. To do this, we’ll need to connect the board to our computer and install the necessary software.
Step 2: Connecting the LED to the ESP32 Development Board
Once the ESP32 development board is set up, the next step is to connect the LED to the board. To do this, we’ll need to connect the anode (positive) of the LED(Long Leg) to a digital pin D3 through a 220ohm resistor on the ESP32 development board and the cathode (negative) of the LED(Short Leg) to a GND pin on the ESP32 development board.

Step 3:Installing the Required Libraries and SDK
To program the ESP32, you will need to install the necessary libraries and software development kit (SDK) that is compatible with the programming language you are using. In this example, we will be using the Arduino Integrated Development Environment (IDE) to program the ESP32.
Here are the steps to install the required libraries and SDK for the ESP32 in the Arduino IDE:
- Download the latest version of the Arduino IDE from the official Arduino website.
- Install the Arduino IDE on your computer by following the on-screen instructions.
- Open the Arduino IDE and click on the File menu, then select Preferences.
- In the Additional Board Manager URLs field, paste the following URL:
https://dl.espressif.com/dl/package_esp32_index.json - Click OK to close the Preferences window.
- Next, click on the Tools menu, then select Board: [Board Name], then click on Boards Manager.
- In the Boards Manager window, search for ESP32.
- Select the entry for the ESP32 by Espressif Systems and click the Install button.
- Wait for the installation to complete, then close the Boards Manager window.
- Finally, select the appropriate board and serial port in the Arduino IDE. You can do this by clicking on the Tools menu, then selecting Board: [Board Name] and Serial Port.
With these steps, you should now have the necessary libraries and SDK installed and be ready to write code to control the LED with the ESP32 using the Arduino IDE.
Step 4: Writing the Code
Now that the LED is connected to the ESP32 development board, we can write the code to turn on the LED. We’ll be using the Arduino Integrated Development Environment (IDE) to write and upload the code to the ESP32 development board.
void setup()
{
pinMode(4, OUTPUT);
}
void loop()
{
digitalWrite(4, HIGH);
delay(1000);
digitalWrite(4, LOW);
delay(1000);
}
The code starts by defining the setup function, which is executed only once when the ESP32 starts up. In the setup function, we set the pin mode for GPIO pin 4 to OUTPUT. This means that we are telling the ESP32 that we want to use GPIO pin 4 to output a signal.
The loop function is executed repeatedly, and in this function, we turn on the LED by writing a high voltage (HIGH) to GPIO pin 4, wait for 1000 milliseconds (1 second), turn off the LED by writing a low voltage (LOW) to GPIO pin 4, and wait for another 1000 milliseconds. This process repeats continuously, causing the LED to turn on and off every second.
Read More: What Is ESP32 : Its Features, Applications, and Limitations
Step 5: Uploading the Code to the ESP32
Once you have written the code to control the LED, it’s time to upload the code to the ESP32. To do this, you need to connect the ESP32 to your computer using a USB cable. Then, in the Arduino IDE, select the appropriate board and serial port and click the upload button to upload the code to the ESP32.
Step 6: Turning On the LED
Finally, to turn on the LED, we need to power on the ESP32 and run the code. Once the code is uploaded, the LED should start turning on and off every second.
Conclusion:
In this blog, we have gone over the steps to turn on an LED using an ESP32 microcontroller. By connecting the LED to the ESP32's GPIO pins, installing the necessary libraries and SDK, writing the code to control the LED, uploading the code to the ESP32, and turning on the LED, we can create a simple and effective project using the ESP
Learn About Fritzing






