minnar xie: arduino: blinky LED!
[youtube http://www.youtube.com/watch?v=7DvY-IAyqgw]
int leds[] = {13, 12, 11, 10, 9, 8, 7, 6, 5, 4};
// The setup() method runs once, when the sketch starts
void setup(){
// initialize the digital pin as an output:
for (int i = 0; i < 10; i++){
pinMode(leds[i], OUTPUT);
}
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop() {
for (int i = 0; i<10; i++){
digitalWrite(leds[i], HIGH); // set the LED on
delay(100);
digitalWrite(leds[i], LOW);
}
for (int i = 9; i>0; i--){
digitalWrite(leds[i], HIGH); // set the LED on
delay(100);
digitalWrite(leds[i], LOW);
}
}