int ledr = 2;
int ledy = 3;
int ledg = 4;
int i=0;
#include<LiquidCrystal.h>
LiquidCrystal lcd(7,8,9,10,11,12);
byte STOP[8]={
B00000,
B01110,
B10011,
B10101,
B11001,
B01110,
B00000,
B00000
};
byte GO[8]={
B01110,
B01110,
B11111,
B10101,
B10101,
B01110,
B01010,
B01010
};
void setup() {
pinMode(ledr,OUTPUT);
pinMode(ledy,OUTPUT);
pinMode(ledg,OUTPUT);
lcd.begin(16,2);
lcd.createChar(0,STOP);
lcd.createChar(1,GO);
}
void loop() {
//RED
digitalWrite(ledr,HIGH);
lcd.setCursor(4,0);
lcd.write(byte(0));
lcd.print(" STOP ");
lcd.write(byte(0));
for(i=0;i<11;i++)
{lcd.setCursor(7,1);
lcd.print(i);
delay(1000);}
digitalWrite(ledy,HIGH);
lcd.setCursor(7,1);
lcd.print("11");
delay(1000);
digitalWrite(ledy,LOW);
lcd.setCursor(7,1);
lcd.print("12");
delay(1000);
digitalWrite(ledy,HIGH);
lcd.setCursor(7,1);
lcd.print("13");
delay(1000);
digitalWrite(ledy,LOW);
lcd.setCursor(7,1);
lcd.print("14");
delay(1000);
digitalWrite(ledy,HIGH);
lcd.setCursor(7,1);
lcd.print("15");
delay(1000);
digitalWrite(ledy,LOW);
digitalWrite(ledr,LOW);
lcd.clear();
//GREEN
digitalWrite(ledg,HIGH);
lcd.setCursor(5,0);
lcd.write(byte(1));
lcd.print(" GO ");
lcd.write(byte(1));
for(i=0;i<11;i++)
{lcd.setCursor(7,1);
lcd.print(i);
delay(1000);}
digitalWrite(ledy,HIGH);
lcd.setCursor(7,1);
lcd.print("11");
delay(1000);
digitalWrite(ledy,LOW);
lcd.setCursor(7,1);
lcd.print("12");
delay(1000);
digitalWrite(ledy,HIGH);
lcd.setCursor(7,1);
lcd.print("13");
delay(1000);
digitalWrite(ledy,LOW);
lcd.setCursor(7,1);
lcd.print("14");
delay(1000);
digitalWrite(ledy,HIGH);
lcd.setCursor(7,1);
lcd.print("15");
delay(1000);
digitalWrite(ledy,LOW);
digitalWrite(ledg,LOW);
lcd.clear();
}
Comments