Hello everybody,
for my schoolproject I have to make a trafficlight that has different modes (Belgium, Netherlands & Germany) but I don't know how to program a button in my program so that I can switch to the next mode while the othter one is still running.
Can someone help me please?
Keep a counter that counts the button presses.
If the counter equals 0, call a function that controls the traffic lights the dutch way, if the counter equals 1, call a function that controls the traffic lights the german way etc.
Once the counter reaches 3, reset to zero.
Make sure that your functions are non-blocking so you can switch without having to wait. A statemachine approach comes to mind for this.