Extra 5% OFF Use Code: OL05
Free Shipping over ₹999

Project 1: Blinking LED with ESP32

Introduction

The Blinking LED project is the simplest way to get started with ESP32. It helps you understand digital output control using code. In this project, we will turn an LED on and off at regular intervals.

Prerequisites / Requirements

If you are new to ESP32, first go through the Introduction to ESP32 before starting this project.

Required Components

  • ESP32 Board
  • LED (5mm)
  • 220Ω Resistor
  • Jumper Wires
  • Breadboard

Pinout

  • LED Anode (+)
  • LED Cathode (-)

Circuit Diagram

  • ESP32 GPIO 2220Ω Resistor → LED (Anode +)
  • ESP32 GNDLED (Cathode -)

Arduino Code

#define LED_PIN 2  // Define LED pin

void setup() {
  pinMode(LED_PIN, OUTPUT);  // Set LED pin as output
}

void loop() {
  digitalWrite(LED_PIN, HIGH);  // Turn LED ON
  delay(1000);                  // Wait 1 second
  digitalWrite(LED_PIN, LOW);   // Turn LED OFF
  delay(1000);                  // Wait 1 second
}

Explanation

  • The LED is connected to GPIO 2 and controlled as an output.
  • The loop() function turns the LED on and off every second.
  • The delay(1000) function creates a 1-second interval between each LED state.

Troubleshooting

  • LED Not Blinking? Check if the resistor is connected correctly.
  • ESP32 Not Uploading? Hold the BOOT button while uploading.
  • Wrong GPIO Pin? Ensure the LED is connected to GPIO 2 as per the code.

    Leave a Reply

    Your email address will not be published.

    Need Help?