int g1=13;
int dp=1000;
int g2=12;
int g3=11;
int g4=10;
int y1=9;
int y2=8;
int y3=7;
int y4=6;
int r1=5;
int r2=4;
int r3=3;
int r4=2;
void setup() {
pinMode( g1, OUTPUT);
pinMode( g2, OUTPUT);
pinMode( g3, OUTPUT);
pinMode( g4, OUTPUT);
pinMode( y1, OUTPUT);
pinMode( y2, OUTPUT);
pinMode( y3, OUTPUT);
pinMode( y4, OUTPUT);
pinMode( r1, OUTPUT);
pinMode( r2, OUTPUT);
pinMode( r3, OUTPUT);
pinMode( r4, OUTPUT);// put your setup code here, to run once:
}
void loop() {
digitalWrite ( y1 , HIGH);
delay(dp);
digitalWrite ( y1 , LOW);
north();
delay(5000);
digitalWrite ( y2 , HIGH);
delay(dp);
digitalWrite ( y2 , LOW);
south();
delay(5000);
digitalWrite ( y3 , HIGH);
delay(dp);
digitalWrite ( y3 , LOW);
est();
delay(5000);
digitalWrite ( y4 , HIGH);
delay(dp);
digitalWrite ( y4 , LOW);
west();
delay(5000);
}
void north()
{
digitalWrite ( g1 , HIGH);
digitalWrite ( g2 , LOW);
digitalWrite ( g3 , LOW);
digitalWrite ( g4 , LOW);
digitalWrite ( r1 , LOW);
digitalWrite ( r2 , HIGH);
digitalWrite ( r3 , HIGH);
digitalWrite ( r4 , HIGH);
}
void south()
{
digitalWrite ( g2 , HIGH);
digitalWrite ( g3 , LOW);
digitalWrite ( g4 , LOW);
digitalWrite ( g1 , LOW);
digitalWrite ( r1 , HIGH);
digitalWrite ( r2 , LOW);
digitalWrite ( r3 , HIGH);
digitalWrite ( r4 , HIGH);
}
void est()
{
digitalWrite ( g3 , HIGH);
digitalWrite ( g1 , LOW);
digitalWrite ( g2 , LOW);
digitalWrite ( g4 , LOW);
digitalWrite ( r1 , HIGH);
digitalWrite ( r2 , HIGH);
digitalWrite ( r3 , LOW);
digitalWrite ( r4 , HIGH);
}
void west()
{
digitalWrite ( g4 , HIGH);
digitalWrite ( g1 , LOW);
digitalWrite ( g2 , LOW);
digitalWrite ( g3 , LOW);
digitalWrite ( r1 , HIGH);
digitalWrite ( r2 , HIGH);
digitalWrite ( r3 , HIGH);
digitalWrite ( r4 , LOW);
}
note -g -ग्रीन लाइट ,r -रेड लाइट , y -येलो लाइट।