ESP32: Blinking an LED

Blinking an LED is one of the simplest and most important starter projects with ESP32. To do this, you need to complete a few basic setup steps.

Prerequisites

  1. Download the Arduino IDE based on your computer's specifications.

  2. Install the necessary libraries for your development board.

Setting Up ESP32 in Arduino IDE

  1. Open Arduino IDE and go to File > Preferences.

  2. In the Additional Board Manager URLs field, paste the following link:
    https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  3. Go to Tools > Board > Boards Manager.

  4. Search for ESP32 and install the ESP32 board package.

  5. Connect your ESP32 board to your computer via USB. On connection you can see the name of the board and the port be selected automatically.

Code

Open a new sketch and enter the following code:



#define LED_BUILTIN 2 // Adjust if your board uses a different pin (e.g., 5) void setup() { pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED pin as output } void loop() { digitalWrite(LED_BUILTIN, HIGH); // Turn the LED on delay(1000); // Wait for 1 second digitalWrite(LED_BUILTIN, LOW); // Turn the LED off delay(1000); // Wait for 1 second }

Upload and Run

  1. Click Verify to compile the code.

  2. Click Upload to upload the code to your ESP32 board.

  3. Once uploading is complete, the built-in LED on the ESP32 will start blinking!



Blinking of LED

Comments

Post a Comment

Popular posts from this blog

Microprocessor vs Microcontroller vs System on Chip

Introduction