byte butt=0; int red=13; int yellow=12; int green=11; int rd=8; int gr=6; int i=0;
void setup() {
pinMode(red, OUTPUT); pinMode(yellow, OUTPUT); pinMode(green, OUTPUT); pinMode(gr, OUTPUT); pinMode(rd, OUTPUT); pinMode(2, INPUT);
}
void loop() {
butt=digitalRead(2); //keeps track if button is pressed
if (butt==0) //if button is pressed
{
delay(1000); // after button pressed wait 1 sec
digitalWrite(green,LOW); digitalWrite(yellow,HIGH); //turn off green and yellow on
delay(1000); // same shit below
digitalWrite(yellow,LOW); digitalWrite(red,HIGH);
delay(1000);
digitalWrite(rd,LOW); digitalWrite(gr,HIGH);
delay(2000);
boop(); // code to make stop walk light blink before turining of walk light and turning on stop walk light
delay(2000);
}
else if (butt==1) //if button isnt pressed
{
digitalWrite(green,HIGH); digitalWrite(rd,HIGH); digitalWrite(gr,LOW); digitalWrite(yellow,LOW); digitalWrite(red,LOW);
}
}
void boop()
{
digitalWrite(rd,HIGH); delay(250); digitalWrite(rd,LOW); delay(250); // code to make stop walk light blink, whiule and for loops didn't work
digitalWrite(rd,HIGH); delay(250); digitalWrite(rd,LOW); delay(250);
digitalWrite(rd,HIGH); delay(250); digitalWrite(rd,LOW); delay(250);
digitalWrite(rd,HIGH); delay(250); digitalWrite(rd,LOW); delay(250);
digitalWrite(rd,HIGH); delay(250); digitalWrite(rd,LOW); delay(250);
digitalWrite(rd,HIGH); // stop walk light on static
digitalWrite(gr,LOW); // walk light turned off
}
Comments