Table of Contents

Play Video

DANCING LED

This project uses an Arduino to create a "dancing" LED display where different LEDs light up in various patterns.

Software Used

Platform Used

This project uses an Arduino to create a “dancing” LED display where different LEDs light up in various patterns. By programming the Arduino, you can control the timing and sequence of the LED lights to create dynamic and visually appealing light shows. This project is great for learning basic Arduino programming and electronics while creating an entertaining and interactive LED display.
Components Required:
1. Arduino Uno
2. 8 LEDs
3. 8 Resistors (220 ohms)
4. Breadboard
5. Jumper Wires
Circuit Connections:
· Connect each LED’s anode (long leg) to a digital pin on the Arduino (e.g., pins 3,5,6,8,9,10,11,13).
· Connect each LED’s cathode (short leg) to a 220-ohm resistor, and then to GND.
// Define the LED pins
const int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9};
const int numLeds = sizeof(ledPins) / sizeof(ledPins[0]);

void setup() {
  // Set all LED pins as outputs
  for (int i = 0; i < numLeds; i++) {
    pinMode(ledPins[i], OUTPUT);
  }
}

void loop() {
  // Pattern 1: Sequential Blink
  for (int i = 0; i < numLeds; i++) {
    digitalWrite(ledPins[i], HIGH);
    delay(100);
    digitalWrite(ledPins[i], LOW);
  }

  // Pattern 2: Back and Forth
  for (int i = numLeds - 1; i >= 0; i--) {
    digitalWrite(ledPins[i], HIGH);
    delay(100);
    digitalWrite(ledPins[i], LOW);
  }

  // Pattern 3: Alternate LEDs
  for (int i = 0; i < numLeds; i++) {
    if (i % 2 == 0) {
      digitalWrite(ledPins[i], HIGH);
    }
  }
  delay(500);
  for (int i = 0; i < numLeds; i++) {
    digitalWrite(ledPins[i], LOW);
  }
  delay(500);

  for (int i = 0; i < numLeds; i++) {
    if (i % 2 != 0) {
      digitalWrite(ledPins[i], HIGH);
    }
  }
  delay(500);
  for (int i = 0; i < numLeds; i++) {
    digitalWrite(ledPins[i], LOW);
  }
  delay(500);

  // Pattern 4: All LEDs On and Off
  for (int i = 0; i < numLeds; i++) {
    digitalWrite(ledPins[i], HIGH);
  }
  delay(500);
  for (int i = 0; i < numLeds; i++) {
    digitalWrite(ledPins[i], LOW);
  }
  delay(500);
}
Scroll to Top