ESP32 Led Blinking

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:

Subramanian
Subramanian

Subramanian MK, currently serving as a workshop instructor at Sakthi Polytechnic College, Erode Tamil Nadu. With a career spanning 25 + years, Subramanian MK has dedicated himself to advancing knowledge in Electronics and Communication Engineering (ECE). His passion for exploring new technologies has led to the development of numerous projects, showcasing expertise in IoT and PCB design.

Articles: 504

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

×

Hi, How can I help you?

×