I'm a newbie to coding
i need help on coding
I'm currently on a project on traffic lights system using LEDs
I have done the pattern and its successfully looping, but there's a function i need to do,
an OVERRIDE FUNCTION, the goal is to stop the current pattern and then changing it to only red lights on both sets with a push of a button (for as long as the button is held)
copy of the code below
//light 1
int red1= 13;
int yellow1= 12;
int green1= 11;
//light 2
int red2= 10;
int yellow2= 9;
int green2= 8;
//buttons
int button1 = 7;
void setup()
{ // light 1
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
//light 2
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
//buttons
pinMode(button1, INPUT);
}
void loop()
{
digitalWrite(red1,1);
digitalWrite(yellow1,0);
digitalWrite(green1,0);
digitalWrite(red2,0);
digitalWrite(yellow2,0);
digitalWrite(green2,1);
delay(5000);
digitalWrite(red1,1);
digitalWrite(yellow1,0);
digitalWrite(green1,0);
digitalWrite(red2,1);
digitalWrite(yellow2,0);
digitalWrite(green2,0);
delay(3000);
digitalWrite(red1,1);
digitalWrite(yellow1,0);
digitalWrite(green1,0);
digitalWrite(red2,1);
digitalWrite(yellow2,1);
digitalWrite(green2,0);
delay(5000);
}



