Chasing Pattern of LED
by mansiramteke139 in Circuits > Microcontrollers
44 Views, 0 Favorites, 0 Comments
Chasing Pattern of LED
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
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
- 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
- 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)