Chasing Pattern of LED

by mansiramteke139 in Circuits > Microcontrollers

44 Views, 0 Favorites, 0 Comments

Chasing Pattern of LED

20241229_123554[1].jpg
20241229_123601[1].jpg
20241227_173922.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:-

  1. Sequential Illumination: LEDs light up one by one, creating the illusion of motion.
  2. Adjustable Speed: The speed of the chasing pattern can be controlled by modifying the time delay between switching LEDs.
  3. Customizable Patterns: Different sequences (left-to-right, right-to-left) can be programmed for variety.
  4. Simple Design: A basic chasing LED circuit can be built with minimal components like LEDs, and a microcontroller.

Applications:-

  1. Decorative Lighting: Used in events, stage lighting, and festivals for dynamic effects.
  2. Signage and Indicators: Common in advertising boards or directional indicators.
  3. Educational Projects: Ideal for learning about circuits, microcontrollers, and programming.

How It Works:-

  1. Control Unit (Microcontroller): A microcontroller like Arduino generates the logic to turn LEDs on and off sequentially.
  2. LEDs : LEDs provide the visual output, and resistors limit the current to protect the LEDs.
  3. Timing Control: A delay between LED activations is implemented to create the perception of smooth motion.

Benefits:-

  1. Easy to build and program.
  2. Visually appealing and engaging.
  3. 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

  1. LEDs
  2. Quantity: As many as required for the chasing effect (e.g., 10-13 LEDs).
  3. Type: Any standard LEDs (5mm red, green, blue, etc.).
  4. Microcontroller
  5. Example: Arduino UNO.
  6. Used to program and control the sequence of LED activation.
  7. Jumper Wires
  8. To connect LEDs, and the microcontroller.
  9. Breadboard or PCB
  10. A breadboard for prototyping the circuit.
  11. Power Supply
  12. Used USB cable as power source for the microcontroller and LEDs.

Gather Components

20241229_144429[1].jpg
20241229_144435[1].jpg
20241229_144450[1].jpg
20241229_144500[1].jpg
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
  1. Each LED is connected to a digital pin on the Arduino through a Jumper wires
  2. The Arduino controls the sequence by turning each LED on and off.

Basic Circuit Layout:

  1. Connect each LED’s positive leg (anode) to an Arduino digital pin through a Jumper wires.
  2. Connect each LED’s negative leg (cathode) to the ground (GND) rail on the breadboard.


Build the Circuit

20241229_145228[1].jpg
20241229_145615[1].jpg
  1. Place the LEDs on the breadboard with their cathodes connected to a common ground rail.
  2. Attach one jumper wires to the anode of each LED.
  3. Connect the other end of each jumper wires to an Arduino digital pin.
  4. Connect the Arduino’s GND to the ground rail on the breadboard.


Write the Arduino Code

Screenshot 2024-12-29 145950.png

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

  1. Connect the Arduino to your computer via USB.
  2. Open the Arduino IDE.
  3. Select the correct board and port under the Tools menu.
  4. Paste the code into the IDE and click the Upload button.

Customize the Pattern

Screenshot 2024-12-29 151554.png
  1. Change the Speed: Modify the delay(500); value for faster or slower patterns.
  2. Change the Sequence: Different loop logic for unique effects (Left to write and right to left)