Translate

Arduino LED Chaser – Running Light Project for Beginners

Introduction

An LED Chaser (also called a "Running Light") is a circuit where multiple LED's turn on and off one after the other to create a chasing effect. In this guide, we will use an Arduino Uno to control four LED's connected to Digital Pins 13, 12, 11, and 10.

🛠️ Components Needed

  • Arduino Uno R3

  • 4 LEDs (Red)

  • 1 Resistor (220Ω or 330Ω)

  • Jumper Wires & Breadboard


🔌 Circuit and Connections



To keep the wiring simple, all LED's share a single ground connection through one resistor:

  • Anodes (Long Legs): Connect to Arduino Digital Pins 13, 12, 11, and 10.

  • Cathodes (Short Legs): All connected together to a single ground rail on your breadboard.

  • Ground: The shared cathode rail connects to the Resistor, which then connects to the Arduino GND pin.


💻 Arduino Code

Copy and paste this code into your Arduino IDE to start the chaser:

void setup() {
  // Set pins 10, 11, 12, and 13 as outputs
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
}

void loop() {
  // Move forward from pin 13 to 10
  for (int pin = 13; pin >= 10; pin--) {
    digitalWrite(pin, HIGH); // Turn LED on
    delay(200);              // Wait 0.2 seconds
    digitalWrite(pin, LOW);  // Turn LED off
  }
}

🔌 Circuit Explanation: The "Ground Rail" Method

In this specific circuit, we are using a Common Resistor setup. This is a very clever way to save space on a breadboard!

  • The Positive Side (Control): Each LED is connected to its own Digital Pin (). These pins act like individual power switches. When the code says HIGH, the "switch" closes, and 5V flows to that specific LED.

  • The Negative Side (Return): All the short legs (Cathodes) are tied together. This is called a "Common Ground."

  • The Resistor's Job: Instead of 4 resistors, we use one  resistor between the common ground and the Arduino GND pin. Since our code only turns on one LED at a time, that single resistor is enough to protect whichever LED is currently lit.


💻 Code Explanation: The "For Loop" Magic

Instead of writing digitalWrite many times, we use a For Loop. This makes the code shorter and more professional.

1. The Setup void setup() The loop for (int pin = 10; pin <= 13; pin++) tells the Arduino: "Start at pin 10, and as long as the number is less than or equal to 13, set that pin as an OUTPUT." It’s a fast way to initialize all pins at once.

2. The Main Loop void loop()

  • HIGH: Sends 5 V to the pin, lighting the LED.

  • Delay (1000 ms): Keeps the light on for 1 seconds so the human eye can see the movement.

  • LOW: Cuts the power to 0 V, turning the LED off before the loop moves to the next pin.


💡 Pro-Tips for Your Readers

  • Speed Control: Change the delay(1000) to 100 for a faster chase, or 500 for more slower one.

  • Resistor Safety: While sharing one resistor works for this chaser, it is better practice in larger projects (where multiple LED's stay on) to give each LED its own resistor.

  • Reverse Direction: Can you modify the code to make the lights "bounce" back and forth?

തുടക്കക്കാർക്കായി ഇലക്ട്രോണിക്സ് ലളിതമായി പഠിക്കാം.

Empowering students in Kerala with hands-on technical skills.