/*
Star Topper
by Brent
*/
int led = 0; // LED 1 position
int led1 = 1; // LED 2 position
int led2 = 2; // LED 3 position
int led3 = 3; // LED 4 position
int led4 = 4; // LED 5 position
int count = 0; // Will use while loop for stepping through the animations
int factor = 200; // For use with the speed up and slow down trace effect
// the setup routine runs on reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
}
// the whole loop runs forever:
void loop() {
while(count < 10) {
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led1, HIGH);
delay(100);
digitalWrite(led1, LOW);
delay(100);
digitalWrite(led2, HIGH);
delay(100);
digitalWrite(led2, LOW);
delay(100);
digitalWrite(led3, HIGH);
delay(100);
digitalWrite(led3, LOW);
delay(100);
digitalWrite(led4, HIGH);
delay(100);
digitalWrite(led4, LOW);
delay(100);
count++;
}
while(count < 20) {
digitalWrite(led4, HIGH);
delay(100);
digitalWrite(led4, LOW);
delay(100);
digitalWrite(led3, HIGH);
delay(100);
digitalWrite(led3, LOW);
delay(100);
digitalWrite(led2, HIGH);
delay(100);
digitalWrite(led2, LOW);
delay(100);
digitalWrite(led1, HIGH);
delay(100);
digitalWrite(led1, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
count++;
}
while(count < 30) {
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led2, HIGH);
delay(100);
digitalWrite(led2, LOW);
delay(100);
digitalWrite(led4, HIGH);
delay(100);
digitalWrite(led4, LOW);
delay(100);
digitalWrite(led1, HIGH);
delay(100);
digitalWrite(led1, LOW);
delay(100);
digitalWrite(led3, HIGH);
delay(100);
digitalWrite(led3, LOW);
delay(100);
count++;
}
while(count < 40) {
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led1, HIGH);
delay(100);
digitalWrite(led2, HIGH);
delay(100);
digitalWrite(led3, HIGH);
delay(100);
digitalWrite(led4, HIGH);
delay(100);
digitalWrite(led4, LOW);
delay(100);
digitalWrite(led3, LOW);
delay(100);
digitalWrite(led2, LOW);
delay(100);
digitalWrite(led1, LOW);
delay(100);
digitalWrite(led, LOW);
delay(100);
count++;
}
while(count < 50) {
digitalWrite(led4, HIGH);
delay(100);
digitalWrite(led3, HIGH);
delay(100);
digitalWrite(led2, HIGH);
delay(100);
digitalWrite(led1, HIGH);
delay(100);
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led1, LOW);
delay(100);
digitalWrite(led2, LOW);
delay(100);
digitalWrite(led3, LOW);
delay(100);
digitalWrite(led4, LOW);
delay(100);
count++;
}
while(count < 67) {
digitalWrite(led, HIGH);
delay(factor);
digitalWrite(led1, HIGH);
delay(factor);
digitalWrite(led2, HIGH);
delay(factor);
digitalWrite(led3, HIGH);
delay(factor);
digitalWrite(led4, HIGH);
delay(factor);
digitalWrite(led, LOW);
delay(factor);
digitalWrite(led1, LOW);
delay(factor);
digitalWrite(led2, LOW);
delay(factor);
digitalWrite(led3, LOW);
delay(factor);
digitalWrite(led4, LOW);
delay(factor);
count++;
factor -= 10;
}
while(count < 80) {
digitalWrite(led, HIGH);
delay(factor);
digitalWrite(led1, HIGH);
delay(factor);
digitalWrite(led2, HIGH);
delay(factor);
digitalWrite(led3, HIGH);
delay(factor);
digitalWrite(led4, HIGH);
delay(factor);
digitalWrite(led, LOW);
delay(factor);
digitalWrite(led1, LOW);
delay(factor);
digitalWrite(led2, LOW);
delay(factor);
digitalWrite(led3, LOW);
delay(factor);
digitalWrite(led4, LOW);
delay(factor);
count++;
}
while(count < 97) {
digitalWrite(led4, HIGH);
delay(factor);
digitalWrite(led3, HIGH);
delay(factor);
digitalWrite(led2, HIGH);
delay(factor);
digitalWrite(led1, HIGH);
delay(factor);
digitalWrite(led, HIGH);
delay(factor);
digitalWrite(led4, LOW);
delay(factor);
digitalWrite(led3, LOW);
delay(factor);
digitalWrite(led2, LOW);
delay(factor);
digitalWrite(led1, LOW);
delay(factor);
digitalWrite(led, LOW);
delay(factor);
count++;
factor += 10;
}
while(count < 100) {
digitalWrite(led4, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led1, HIGH);
digitalWrite(led, HIGH);
delay(200);
digitalWrite(led4, LOW);
digitalWrite(led3, LOW);
digitalWrite(led2, LOW);
digitalWrite(led1, LOW);
digitalWrite(led, LOW);
delay(200);
count++;
}
factor = 200;
count = 0;
}
Comments