Chasing Pattern of LED
by mansiramteke139 in Circuits > Microcontrollers
61 Views, 0 Favorites, 0 Comments
Chasing Pattern of LED
![20241229_123554[1].jpg](/proxy/?url=https://content.instructables.com/F2J/5I9X/M586ZJZT/F2J5I9XM586ZJZT.jpg&filename=20241229_123554[1].jpg)
![20241229_123601[1].jpg](/proxy/?url=https://content.instructables.com/F5P/D0V4/M586ZJZZ/F5PD0V4M586ZJZZ.jpg&filename=20241229_123601[1].jpg)

Introduction to Chasing Pattern LED:-
A Chasing Pattern LED is an electronic circuit or system designed to light up multiple LEDs in a sequential manner, creating a "chasing" or "running" visual effect. This pattern is widely used in decorative lighting, indicators, and entertainment displays. The effect is achieved by turning on and off each LED in a sequence with a specific time delay.
Key Features:-
- Sequential Illumination: LEDs light up one by one, creating the illusion of motion.
- Adjustable Speed: The speed of the chasing pattern can be controlled by modifying the time delay between switching LEDs.
- Customizable Patterns: Different sequences (left-to-right, right-to-left) can be programmed for variety.
- Simple Design: A basic chasing LED circuit can be built with minimal components like LEDs, and a microcontroller.
Applications:-
- Decorative Lighting: Used in events, stage lighting, and festivals for dynamic effects.
- Signage and Indicators: Common in advertising boards or directional indicators.
- Educational Projects: Ideal for learning about circuits, microcontrollers, and programming.
How It Works:-
- Control Unit (Microcontroller): A microcontroller like Arduino generates the logic to turn LEDs on and off sequentially.
- LEDs : LEDs provide the visual output, and resistors limit the current to protect the LEDs.
- Timing Control: A delay between LED activations is implemented to create the perception of smooth motion.
Benefits:-
- Easy to build and program.
- Visually appealing and engaging.
- Serves as an educational tool for learning basic electronics and programming.
Code:-
const int numLEDs = 13; // Number of LEDs
int ledPins[] = {0,1,2, 3, 4, 5,6,7,8,9,10,11,12}; // Pins connected to LEDs
void setup() {
for (int i = 0; i < numLEDs; i++) {
pinMode(ledPins[i], OUTPUT); // Set LED pins as output
}
}
void loop() {
// Chasing pattern from left to right
for (int i = 0; i < numLEDs; i++) {
digitalWrite(ledPins[i], HIGH); // Turn on the current LED
delay(500); // Delay for a while
digitalWrite(ledPins[i], LOW); // Turn off the current LED
}
// Chasing pattern from right to left
for (int i = numLEDs - 1; i >= 0; i--) {
digitalWrite(ledPins[i], HIGH);
delay(500);
digitalWrite(ledPins[i], LOW);
}
}
Supplies
Essential Components
- LEDs
- Quantity: As many as required for the chasing effect (e.g., 10-13 LEDs).
- Type: Any standard LEDs (5mm red, green, blue, etc.).
- Microcontroller
- Example: Arduino UNO.
- Used to program and control the sequence of LED activation.
- Jumper Wires
- To connect LEDs, and the microcontroller.
- Breadboard or PCB
- A breadboard for prototyping the circuit.
- Power Supply
- Used USB cable as power source for the microcontroller and LEDs.
Gather Components
![20241229_144429[1].jpg](/proxy/?url=https://content.instructables.com/F59/OEPJ/M586ZKHO/F59OEPJM586ZKHO.jpg&filename=20241229_144429[1].jpg)
![20241229_144435[1].jpg](/proxy/?url=https://content.instructables.com/F7Y/9BTL/M586ZKHY/F7Y9BTLM586ZKHY.jpg&filename=20241229_144435[1].jpg)
![20241229_144450[1].jpg](/proxy/?url=https://content.instructables.com/F7J/OA6K/M586ZKI8/F7JOA6KM586ZKI8.jpg&filename=20241229_144450[1].jpg)
![20241229_144500[1].jpg](/proxy/?url=https://content.instructables.com/F1M/6VJY/M586ZKIJ/F1M6VJYM586ZKIJ.jpg&filename=20241229_144500[1].jpg)
![20241229_144509[1].jpg](/proxy/?url=https://content.instructables.com/FBH/MNDJ/M586ZKIV/FBHMNDJM586ZKIV.jpg&filename=20241229_144509[1].jpg)
Arduino UNO: 1 unit
LEDs: 13 LEDs
Breadboard: 1 unit
Jumper Wires: F-F
Power Supply: USB cable to power the Arduino
Understand the Circuit Design
![20241229_145230[1].jpg](/proxy/?url=https://content.instructables.com/FFI/1A3G/M586ZKM8/FFI1A3GM586ZKM8.jpg&filename=20241229_145230[1].jpg)
- Each LED is connected to a digital pin on the Arduino through a Jumper wires
- The Arduino controls the sequence by turning each LED on and off.
Basic Circuit Layout:
- Connect each LED’s positive leg (anode) to an Arduino digital pin through a Jumper wires.
- Connect each LED’s negative leg (cathode) to the ground (GND) rail on the breadboard.
Build the Circuit
![20241229_145228[1].jpg](/proxy/?url=https://content.instructables.com/FK4/F4QH/M586ZKR4/FK4F4QHM586ZKR4.jpg&filename=20241229_145228[1].jpg)
![20241229_145615[1].jpg](/proxy/?url=https://content.instructables.com/F54/A2WH/M586ZKR5/F54A2WHM586ZKR5.jpg&filename=20241229_145615[1].jpg)
- Place the LEDs on the breadboard with their cathodes connected to a common ground rail.
- Attach one jumper wires to the anode of each LED.
- Connect the other end of each jumper wires to an Arduino digital pin.
- Connect the Arduino’s GND to the ground rail on the breadboard.
Write the Arduino Code

Used the following sample code to create a basic chasing pattern:
const int numLEDs = 13; // Number of LEDs
int ledPins[] = {0,1,2, 3, 4, 5,6,7,8,9,10,11,12}; // Pins connected to LEDs
void setup() {
for (int i = 0; i < numLEDs; i++) {
pinMode(ledPins[i], OUTPUT); // Set LED pins as output
}
}
void loop() {
// Chasing pattern from left to right
for (int i = 0; i < numLEDs; i++) {
digitalWrite(ledPins[i], HIGH); // Turn on the current LED
delay(500); // Delay for a while
digitalWrite(ledPins[i], LOW); // Turn off the current LED
}
// Chasing pattern from right to left
for (int i = numLEDs - 1; i >= 0; i--) {
digitalWrite(ledPins[i], HIGH);
delay(500);
digitalWrite(ledPins[i], LOW);
}
}
Upload the Code
- Connect the Arduino to your computer via USB.
- Open the Arduino IDE.
- Select the correct board and port under the Tools menu.
- Paste the code into the IDE and click the Upload button.
Customize the Pattern

- Change the Speed: Modify the delay(500); value for faster or slower patterns.
- Change the Sequence: Different loop logic for unique effects (Left to write and right to left)