Blinking Lights Program


 

 

 

See detailed explanation of Blink at

 

http://arduino.cc/en/Tutorial/Blink

 

See video explanation of this project at:

http://k12videos.mit.edu/content/arduino-tutorial-1--

 

what hardware components were omitted?


// each LED is connected through a 220 ohm resistor
// to the indicated digital pin
// long lead is +
// short lead is connected to ground

 

//set the pin ports

 

int ledA = 4;
int ledB = 5;
int ledC = 6;
 int ledD = 7;

 

//set LED pins as output pins


void setup() {
pinMode(ledA, OUTPUT);
pinMode(ledB, OUTPUT);
pinMode(ledC, OUTPUT);
pinMode(ledD, OUTPUT);
}

 
//actual loop for blinking lights; each LED is turn on then off in series
//make sure that the function is enclosed in brackets {}, not parentheses ()
//and that each statement ends with a semicolon;

 

void loop() {
digitalWrite(ledA, HIGH);
delay(125);
digitalWrite(ledA, LOW);
delay(125);

digitalWrite(ledB, HIGH);
delay(125);
digitalWrite(ledB, LOW);
delay(125);

digitalWrite(ledC, HIGH);
delay(125);
digitalWrite(ledC, LOW);
delay(125);

digitalWrite(ledD, HIGH);
delay(125);
digitalWrite(ledD, LOW);
delay(125);
}