hey, so Im doing a little project, I need to have an LED intersection with a button and pedestrian lights. I have everything wired up and stuff, however I don't know how to input a working pedestrian light with a button on my code. Help?
CODE IS BELOW
// Connect green LED to pin 13 and 10
// Connect yellow LED to pin 12 and 9
// Connect red LED to pin 11 and 8
int var = 0;
int button = 2;
void setup() {
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(2, INPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop(){{delay(500);
if (var == 0)
digitalWrite(8, HIGH);
var = 1;
if (var == 1)
digitalWrite(13, HIGH);
var = 0; }
{ delay(350);
if (var == 0)
digitalWrite(13, LOW);
var = 1;
if (var == 1)
digitalWrite(12, HIGH);
var = 2;}
{
delay(500);
if (var == 2)
digitalWrite(11, HIGH);
var = 2;
if (var == 2)
digitalWrite(12, LOW);
var = 3;
}
{ delay(500);
if (var == 3)
digitalWrite(11, HIGH);
var = 4;
if (var == 4)
digitalWrite(8, HIGH);
var = 3;
}{
delay(300);
if (var == 3)
digitalWrite(11, HIGH);
var = 2;
if (var == 2)
digitalWrite(8, LOW);
var = 2;
if (var == 2)
digitalWrite(10, HIGH);
var = 4;}
{ delay(500);
if (var == 4)
digitalWrite(11, HIGH);
var = 2;
if (var == 2)
digitalWrite(10, LOW);
var = 3;
if (var == 3)
digitalWrite(9, HIGH);
var = 2; }
{ delay(300);
if (var == 2)
digitalWrite(9, LOW);
var = 3;
if (var == 3)
digitalWrite(8, HIGH);
var = 4;
if (var == 4)
digitalWrite(11, HIGH);
var = 3; }
{delay(300);
if (var == 3)
digitalWrite(8, HIGH);
var = 4;
if (var == 4)
digitalWrite(11, HIGH);
var = 3; }
{
if (var == 3)
digitalWrite(11, LOW);
var = 2;
if (var == 2)
digitalWrite (13, HIGH);
var = 3; }
}