I have a school project, where I'm going to make a traffic light system on a pls. I want to try it out on an Arduino first, just to get the hang of it.
To make it a little bit more advanced than I have found on the internet, I want to make the lights go in "emergency mode" if the green lights in both directions are on at the same time. It will then go into a yellow blink.
My idea is something like this:
// Yellow blinking if fault in the system or operator activates it
int killState = digitalRead(Kill);
int resState = digitalRead(Res);
if (killState == HIGH /*|| greenlights in both directions */) {
while (resState == LOW;) { // Yellow blink as long as system is not reset
BLINK();
}
}
I guess I need a variable or two that tells what state the lights are in, but I'm stuck. Any good solutions out there?
Another thing is the reset button. I haven't put much effort in it, but I want it to go into the starting point.
The link to the complete script can be found here.