Free Nationwide Doorstep Delivery on orders over ₹499
← All 10 Projects•Beginner•30 mins

LED Blinking & Digital Output

Understand GPIO pins, digital logic levels (HIGH/LOW), and timing control by pulsing an LED at configured intervals.

Real-World Engineering Application

Turn indicators in automobiles, heartbeat status LEDs in medical equipment, and warning beacon lights.

Physics & Working Principle

A microcontroller pin configured as OUTPUT switches between 3.3V/5V (HIGH) and 0V (LOW). A current-limiting resistor prevents excessive current from burning out the LED according to Ohm’s Law (I = (V_pin - V_f) / R).

Key Learning Outcome:Master GPIO configuration, pinMode(), digitalWrite(), delay() timing, and calculating current-limiting resistor values.

Pin Connection & Wiring Table

Component Pin / TerminalMicrocontroller Pin (ESP32 / Arduino)Wiring Note
LED Anode (Long Leg)GPIO 2 (ESP32) / Pin 13 (Arduino)Connect via 220Ω resistor
LED Cathode (Flat side/Short)GNDDirect connection to common ground

Step-by-Step Plug & Play Assembly

1

Connect the LED to the plug-and-play module so the two pins sit in separate terminal ports.

2

Place a 220Ω resistor in series between GPIO 2 and the LED anode (longer leg).

3

Connect the short leg (cathode) of the LED directly to the microcontroller GND rail.

4

Connect your development board to the computer using the USB cable.

Complete Tested Source Code

// NovaCircuit Project 1: LED Blinking
const int LED_PIN = 2; // Onboard LED on ESP32 or external LED

void setup() {
  pinMode(LED_PIN, OUTPUT);
  Serial.begin(115200);
  Serial.println("NovaCircuit LED Blinker Initialized");
}

void loop() {
  digitalWrite(LED_PIN, HIGH);
  Serial.println("LED State: ON");
  delay(1000); // 1000 milliseconds ON
  
  digitalWrite(LED_PIN, LOW);
  Serial.println("LED State: OFF");
  delay(1000); // 1000 milliseconds OFF
}
Code Logic Breakdown:

pinMode(LED_PIN, OUTPUT) configures the silicon pin driver for sourcing current. digitalWrite(LED_PIN, HIGH) outputs logic level 1, turning the LED on, while delay(1000) pauses execution for 1000ms.

Expected Physical Output

The external LED illuminates for 1 second, shuts off for 1 second, and repeats continuously while logging state to the Serial Monitor.
Troubleshooting Tips
  • •LED not turning on: Check LED polarity. The longer wire is positive (anode).
  • •Dim LED: Ensure resistor value is not too high (use 220Ω - 330Ω, do not use 100kΩ).
  • •Code upload failed: Ensure correct COM port is chosen in Arduino IDE.
Electrical Safety Directives
  • •Always disconnect the USB cable before altering circuit wiring.
  • •Never connect an LED directly to GPIO pins without a current-limiting resistor.
Companion Resources

Related Book Chapter & Hardware Kit

Covered in depth within Chapter 4: LEDs, Switches and Basic Circuits. Build this easily with the Electronics Starter Kit.