byte ledPin[] = {5, 6, 7, 8, 9, 10, 11, 12,};
int ledDelay(100);
int direction = 1;
int currentLED = 0;
int maxHeight = 7;
unsigned long changeTime;
void setup() {
for(int x=0; x<8; x++){
pinMode(ledPin[x], OUTPUT);
}
changeTime = millis();
}
void loop() {
if((millis() - changeTime) > ledDelay){
changeLED();
changeTime = millis();
}
}
void changeLED() {
for(int x=0; x<8; x++){
digitalWrite(ledPin[x], LOW);
}
digitalWrite(ledPin[currentLED], HIGH);
currentLED += direction;
if(currentLED == maxHeight){
direction = -1;
}
if(currentLED == 0){
direction = 1;
maxHeight -= 1;
}
if(maxHeight == 0){
maxHeight = 7;
}
}
int ledDelay(100);
int direction = 1;
int currentLED = 0;
int maxHeight = 7;
unsigned long changeTime;
void setup() {
for(int x=0; x<8; x++){
pinMode(ledPin[x], OUTPUT);
}
changeTime = millis();
}
void loop() {
if((millis() - changeTime) > ledDelay){
changeLED();
changeTime = millis();
}
}
void changeLED() {
for(int x=0; x<8; x++){
digitalWrite(ledPin[x], LOW);
}
digitalWrite(ledPin[currentLED], HIGH);
currentLED += direction;
if(currentLED == maxHeight){
direction = -1;
}
if(currentLED == 0){
direction = 1;
maxHeight -= 1;
}
if(maxHeight == 0){
maxHeight = 7;
}
}