Blinking LedTo create a program that blinks the built-in LED on an ESP32, you’ll need to use the Arduino IDE. Here’s a simple example code to accomplish this.
Install the ESP32 Board in Arduino IDE:
STEP-1: Open Arduino IDE.
STEP-2: Go to File > Preferences.
STEP-3: In the “Additional Board Manager URLs” field, add this URL:
https://dl.espressif.com/dl/package_esp32_index.json,
STEP-4: Go to Tools > Board > Boards Manager.
STEP-5: Search for ESP32 and install the esp32 by Espressif Systems.
STEP-6: Select the ESP32 Board.
STEP-7: Go to Tools > Board and select your specific ESP32 board (e.g., “ESP32 Dev Module”).
Write the Blinking LED Code:
Open a new sketch (File > New).
Copy and paste the following code into the sketch:
// Define the pin for the built-in LED. For most ESP32 boards, it’s GPIO 2.
const int ledPin = 2; void setup() { pinMode(ledPin, OUTPUT); } void loop() { digitalWrite(ledPin, HIGH); delay(500); digitalWrite(ledPin, LOW); delay(500); }
How to upload Program:
1. Upload the Code to Your ESP32:
2. Connect your ESP32 board to your computer using a USB cable.
3. Select the correct port: Tools > Port > select the COM port that your ESP32 is connected to.
4. Click on the upload button (right arrow icon) to upload the code to the ESP32.
5. This code will make the built-in LED on the ESP32 blink on and off every 500 milliseconds. The ledPin is set to 6. GPIO 2, which is typically the built-in LED pin for most ESP32 boards, but it may vary depending on your specific board. If your board uses a different pin for the built-in LED, you will need to adjust the ledPin value accordingly.
VIDEO TUTORIAL: