Ten led flashing 2

 Ten LED flashing project 2
Arduino Uno - 01
330 Ohm Resistors - 10
Led - 10
Breadboard - 01
Jumper Wires


                           Arduino Sketch 
int timer = 250;                                                                         // Wait for 250 millisecond(s)
int ledPins[] = {0,1,2,3,4,5,6,7,8,9};                                    // an array of pin numbers to which LEDs are attached
int pinCount = 10;                                                                          // Number of pins
void setup(){                                                                                      // Function is called when sketch start 
  for (int thispin = 0; thispin <pinCount;thispin++){     // use a pin 0 to 9 as an output loop
    pinMode(ledPins[thispin],OUTPUT);
  }
}
void loop(){
  for (int thispin = 0; thispin <pinCount;thispin++){         // loop from the lowest pin to the highest
    digitalWrite(ledPins[thispin],HIGH);                                  // LED on
    delay(timer);                                                                                    // Wait for 250 millisecond(s) 
    digitalWrite(ledPins[thispin],LOW);                                    // LED Off 
  }
  for (int thispin = pinCount - 1;thispin >= 0;thispin--){      // loop from the highest pin to the lowest
    digitalWrite(ledPins[thispin],HIGH);                                       // LED On
    delay(timer);                                                                                         // Wait for 250 millisecond(s)   
    digitalWrite(ledPins[thispin],LOW);                                        // LED Off
  }
}

Comments