LED Blinking & Digital Output
Understand GPIO pins, digital logic levels (HIGH/LOW), and timing control by pulsing an LED at configured intervals.
Turn indicators in automobiles, heartbeat status LEDs in medical equipment, and warning beacon lights.
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).
Pin Connection & Wiring Table
| Component Pin / Terminal | Microcontroller Pin (ESP32 / Arduino) | Wiring Note |
|---|---|---|
| LED Anode (Long Leg) | GPIO 2 (ESP32) / Pin 13 (Arduino) | Connect via 220Ω resistor |
| LED Cathode (Flat side/Short) | GND | Direct connection to common ground |
Step-by-Step Plug & Play Assembly
Connect the LED to the plug-and-play module so the two pins sit in separate terminal ports.
Place a 220Ω resistor in series between GPIO 2 and the LED anode (longer leg).
Connect the short leg (cathode) of the LED directly to the microcontroller GND rail.
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
}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
- •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.
- •Always disconnect the USB cable before altering circuit wiring.
- •Never connect an LED directly to GPIO pins without a current-limiting resistor.
Related Book Chapter & Hardware Kit
Covered in depth within Chapter 4: LEDs, Switches and Basic Circuits. Build this easily with the Electronics Starter Kit.