Code: Select all
//Project 01: Blinking lights.
//Led's are on pins 10, 7, 4.
int leds[3] = {10, 7, 4};
const int ledsCount = sizeof(leds) / sizeof(leds[0]);
int led = 0;
void setup() {
//This runs at the start of the program once. As setup!
//Pinmode sets the function of a pin, so if you want to write to pin 8 you have to set its pinmode to OUTPUT.
for(int i = 0; i < ledsCount; i++)
pinMode(leds[i], OUTPUT);
}
void loop() {
//This runs after setup, in a loop until the end of time. (or your arduino turns off.)
// V This is digital, so HIGH means 5V and LOW means 0V (basically ON and OFF).
digitalWrite(leds[led], HIGH);
delay(250);
digitalWrite(leds[led], LOW);
if(++led >= ledsCount)
led = 0;
}