Introduction: Arduino LED 3,2,1 Countdown Timer
Even though I have been using an arduino for a year and a half or so, I never made an effort to learn the language until now. This is my first project with an arduino that I built and coded all by myself. If anyone is interested, here is the code:
void setup() {
pinMode(2,OUTPUT); //red LED
pinMode(3,OUTPUT); // yellow LED
pinMode(1,OUTPUT); // green LED
pinMode(4,OUTPUT); // "go" sign
}
void loop(){
digitalWrite(2,HIGH);
delay(1000);
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
delay(1000);
digitalWrite(3,LOW);
digitalWrite(1,HIGH);
delay(1000);
digitalWrite(1,LOW);
delay(500);
digitalWrite(4,HIGH);
delay(500);
digitalWrite(4,LOW);
delay(500) ;
digitalWrite(4,HIGH);
delay(500);
digitalWrite(4,LOW);
delay(500);
digitalWrite(4,HIGH);
delay(500);
digitalWrite(4,LOW);
delay(500);
digitalWrite(4,HIGH);
delay(500);
digitalWrite(4,LOW);
delay(500);
digitalWrite(4,HIGH);
delay(500);
digitalWrite(4,LOW);
delay(500);
digitalWrite(4,HIGH);
delay(500);
digitalWrite(4,LOW);
}
void setup() {
pinMode(2,OUTPUT); //red LED
pinMode(3,OUTPUT); // yellow LED
pinMode(1,OUTPUT); // green LED
pinMode(4,OUTPUT); // "go" sign
}
void loop(){
digitalWrite(2,HIGH);
delay(1000);
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
delay(1000);
digitalWrite(3,LOW);
digitalWrite(1,HIGH);
delay(1000);
digitalWrite(1,LOW);
delay(500);
digitalWrite(4,HIGH);
delay(500);
digitalWrite(4,LOW);
delay(500) ;
digitalWrite(4,HIGH);
delay(500);
digitalWrite(4,LOW);
delay(500);
digitalWrite(4,HIGH);
delay(500);
digitalWrite(4,LOW);
delay(500);
digitalWrite(4,HIGH);
delay(500);
digitalWrite(4,LOW);
delay(500);
digitalWrite(4,HIGH);
delay(500);
digitalWrite(4,LOW);
delay(500);
digitalWrite(4,HIGH);
delay(500);
digitalWrite(4,LOW);
}