Watch the lights, follow the timer, see why the code moves on.
Vehicles
Pedestrians
Select any state or drag the timeline to inspect it. Each new state starts its own elapsed timer at zero.
phase and started survive between loop passes. now and elapsed are calculated again each pass. The timer checks time without pausing the program.
void enter(Phase next, unsigned long now) {
phase = next; started = now;
}&& requires both conditions to be true. The else if chain allows one timed transition per pass. Afterwards, elapsed is recalculated and the outputs use the new phase.
The shield’s D8, D12 and D13 LEDs represent these pedestrian signals. Green is on only in READY and REQUESTED; WALK is on only in WALK. They never overlap.
The input must stay stable for 25 ms before it is accepted. Holding the button does not create another press. During CLEARANCE, WAIT changes every 250 ms: a full flash takes 500 ms.
Then inspect WALK and press the request button again. Explain which condition prevents the sequence from restarting.