// Define the LED pins
const int ledPins[] = {0, 1, 2, 3, 4, 5}; // Pins connected to LEDs
void setup() {
// Start serial communication at 9600 baud rate
Serial.begin(9600);
// Initialize the LED pins as outputs
for (int i = 0; i < 6; i++) {
pinMode(ledPins[i], OUTPUT);
}
// Print the message to Serial Monitor
Serial.println("LED Chasing Patterns Initialized");
}
void loop() {
// Case 1: Chase LEDs forward
Serial.println("Case 1: Chase LEDs forward");
for (int i = 0; i < 6; i++) {
digitalWrite(ledPins[i], HIGH);
delay(100);
digitalWrite(ledPins[i], LOW);
}
// Case 2: Chase LEDs backward
Serial.println("Case 2: Chase LEDs backward");
for (int i = 5; i >= 0; i--) {
digitalWrite(ledPins[i], HIGH);
delay(100);
digitalWrite(ledPins[i], LOW);
}
// Case 3: Blink all LEDs together
Serial.println("Case 3: Blink all LEDs together");
for (int i = 0; i < 3; i++) { // Blink 3 times
for (int j = 0; j < 6; j++) {
digitalWrite(ledPins[j], HIGH);
}
delay(200);
for (int j = 0; j < 6; j++) {
digitalWrite(ledPins[j], LOW);
}
delay(200);
}
// Case 4: Alternate LEDs
Serial.println("Case 4: Alternate LEDs");
for (int i = 0; i < 3; i++) { // Repeat 3 times
for (int j = 0; j < 6; j += 2) {
digitalWrite(ledPins[j], HIGH);
}
delay(200);
for (int j = 0; j < 6; j += 2) {
digitalWrite(ledPins[j], LOW);
}
for (int j = 1; j < 6; j += 2) {
digitalWrite(ledPins[j], HIGH);
}
delay(200);
for (int j = 1; j < 6; j += 2) {
digitalWrite(ledPins[j], LOW);
}
}
// Case 5: Knight Rider effect
Serial.println("Case 5: Knight Rider effect");
for (int i = 0; i < 6; i++) {
digitalWrite(ledPins[i], HIGH);
delay(100);
digitalWrite(ledPins[i], LOW);
}
for (int i = 4; i > 0; i--) {
digitalWrite(ledPins[i], HIGH);
delay(100);
digitalWrite(ledPins[i], LOW);
}
}
tiny:PB5
tiny:PB3
tiny:PB4
tiny:GND
tiny:PB0
tiny:PB1
tiny:PB2
tiny:VCC
r1:1
r1:2
led:A
led:C
led1:A
led1:C
led2:A
led2:C
led3:A
led3:C
led4:A
led4:C
led5:A
led5:C