Pedestrian Crossing
hard
Adds a queued pedestrian request and walk phase to a two-direction traffic light.
What it teaches
Keeps Traffic Light 2-Way’s Enable control, then adds an event queue. A one-shot records one button press, a latch remembers it, and the state machine serves it only after all-red.
Inputs and outputs
| Tag | Type | Default | Description |
|---|---|---|---|
| In_Enable | BOOL | — | 1 runs the crossing; 0 resets it and shows red in both directions |
| In_WalkRequest | BOOL | — | Pedestrian push button |
| Cfg_GreenTime | DINT | 3000 | Duration of each green phase in milliseconds |
| Cfg_AmberTime | DINT | 1500 | Duration of each amber phase in milliseconds |
| Cfg_AllRedTime | DINT | 2000 | Duration of each all-red phase in milliseconds |
| Cfg_WalkTime | DINT | 2500 | Duration of the walk phase in milliseconds |
| Out_NSGreen | BOOL | — | North-south green light |
| Out_NSAmber | BOOL | — | North-south amber light |
| Out_NSRed | BOOL | — | North-south red light |
| Out_EWGreen | BOOL | — | East-west green light |
| Out_EWAmber | BOOL | — | East-west amber light |
| Out_EWRed | BOOL | — | East-west red light |
| Out_Walk | BOOL | — | Pedestrian walk signal |
| Sts_Waiting | BOOL | — | 1 while a new walk request is queued |
Required behavior
- When In_Enable is 0, both directions show red, Out_Walk is 0, and any queued request is cleared.
- Without a request, the six traffic phases match Traffic Light 2-Way.
- Each 0-to-1 transition of In_WalkRequest queues one request and turns on Sts_Waiting.
- A queued request never shortens green or amber. It is served after the next all-red phase.
- During the walk phase, both traffic directions stay red and Out_Walk is 1 for Cfg_WalkTime.
- Starting a walk clears the queued request. A new press during the walk queues another request for a later gap.
- Holding the button does not create repeated requests. The button must be released before another press is counted.