
PLC traffic light ladder logic with a pedestrian crossing is a sequence of six timed states: vehicle green, vehicle amber, all red, walk, a flashing clearance, and all red again. A pedestrian button asks for the crossing, and the ladder logic must remember that request until it is served. You can build it with one timer per state or with one state number and one timer. This guide gives the state table, both builds, a safe start-up and a test sheet you can run in a free lab.
This is a training exercise. Roadside signals use certified traffic controllers with their own safety rules, and nothing here is a design basis for a real junction.
What the controller must do
Start with the brief, in plain words. Vehicles have a green, amber and red light. Pedestrians have a walk and a don't walk signal. Normally vehicles have green and pedestrians wait. When someone presses the button, the controller finishes a minimum green time, changes vehicles to amber and then red, gives the pedestrians a walk signal, then a flashing clearance, and returns to green.
That brief gives you the inputs and outputs.
- Input: the pedestrian push button (normally open).
- Outputs: vehicle red, vehicle amber, vehicle green, pedestrian walk and pedestrian don't walk.
- Rules: one vehicle light at a time, never green and walk together, amber always before red, and a short button press must never be lost.
Write the rules as a short list before you open any software. Most failed student programs fail because the rules were never written down.
The states and timings
A crossing is a state machine. Each state has fixed light outputs and a fixed duration, and one event moves you to the next. The table shows the six states, the values we use in training, and where the reference numbers come from.
| State | Vehicle lights | Pedestrian lights | Training time | Reference |
|---|---|---|---|---|
| 1 Vehicle green | Green | Don't walk | 10 s minimum, then waits for a request | Our choice |
| 2 Vehicle amber | Amber | Don't walk | 3 s | FHWA: about 3 to 6 s, 3.0 s at 25 mph |
| 3 All red | Red | Don't walk | 2 s | FHWA: red clearance should not exceed 6 s |
| 4 Walk | Red | Walk | 7 s | FHWA: MUTCD minimum walk 7 s (4 s at low pedestrian volume) |
| 5 Pedestrian clearance | Red | Flashing don't walk | 12 s | Crossing distance divided by walking speed |
| 6 All red | Red | Don't walk | 2 s | Our choice |
The numbers in the reference column come from the US Federal Highway Administration's Traffic Signal Timing Manual, chapter 5, which we read on 23 November 2026. It is an archived edition, replaced by a second edition, so treat it as a teaching reference. It states that pedestrian clearance time is the crossing distance divided by the walking speed. Its example is a 60 ft crossing, which needs 17 s at 3.5 ft/s and 20 s at 3.0 ft/s.
We use metric in the lab. A 12 m crossing at 1.07 m/s (that is 3.5 ft/s) needs 12 / 1.07 = 11.2 s, so we round up to 12 s. Always round clearance time up, never down.

PLC traffic light ladder logic with one timer per state
The first build is the one most students write, and it is a good first build because you can read it. Use six on-delay timers, one for each state. Each timer starts when its state begins, and its done bit starts the next one.
| Timer | Starts when | Preset | Done bit moves to |
|---|---|---|---|
| T_MINGREEN | Vehicle green begins | 10 s | Wait for the request |
| T_AMBER | Request is present and min green is done | 3 s | All red |
| T_RED1 | Amber done | 2 s | Walk |
| T_WALK | Red1 done | 7 s | Clearance |
| T_CLEAR | Walk done | 12 s | All red 2 |
| T_RED2 | Clearance done | 2 s | Vehicle green |
Now drive each light from the state, not from the timers. Vehicle red is on in states 3 to 6. Vehicle amber is on in state 2. Vehicle green is on in state 1. Walk is on in state 4. Don't walk is on in every other state, and it flashes in state 5. If every output comes from one place, two lights can never be on because two timers overlapped.
The weakness of this build is that a state is only a pattern of timer bits. If you forget one reset, two timers run at once and the lights misbehave in ways that are hard to see. That is the reason the next build exists.
The Pen Test Partners walk-through of ladder logic (1 June 2020) builds a single traffic light on OpenPLC with timers and negated contacts so only one light is on at a time. It suggests a four-way junction as the next step, which is a good follow-on once the crossing works.
The cleaner version: one state number and one timer
Store the current state in an integer, 1 to 6. Use one on-delay timer. Its preset is chosen by the state: 10 s in state 1, 3 s in state 2, and so on from the table. When the timer is done, add one to the state, wrap from 6 back to 1, and reset the timer. Then compare the state number to switch each output.
This is how a software engineer would write it, and it has three advantages.
- The state can only have one value, so two lights cannot be on from different steps.
- Changing a time means changing one number in one table.
- A test is easy: force the state number and check the outputs.
The only special case is state 1. There the timer is a minimum green time, and the state only moves on when the minimum has elapsed and a request exists. Without a request the vehicles keep green for as long as they need.
The same logic works in CODESYS, OpenPLC, TIA Portal and Studio 5000, because the idea is a state number and a timer, not a vendor instruction. Our free courses teach the timers in each platform, for example CODESYS and IEC 61131-3 and the Allen-Bradley RSLogix 500 course, which has a module of tank level, traffic lights and elevator projects. For timer behaviour, see PLC timers TON, TOF and TP.
Latch the pedestrian request
A button press lasts a fraction of a second, but the crossing may not start for ten seconds. So the program must remember the press. This is the classic seal-in from start/stop ladder logic, used for a different job.
| Rung | Condition | Action |
|---|---|---|
| 1 | Button OR request contact, AND NOT (state 4 or state 5) | Request coil on |
| 2 | Request AND state 1 AND min green done | Allow the move to amber |
| 3 | State 4 begins | Clear the request |
The request coil holds itself on through its own contact. It is blocked during walk and clearance, so a press at that time is ignored, which is our choice. Some designs remember the press for the next cycle instead. Write down whichever you choose and test it.
One trap to avoid: do not clear the request when the button is released. The request ends when the crossing is served, not when the finger lifts. Another is to wire the button straight to the amber state. That works only while the button is held, so a short press is lost.

A safe default: start-up and stalls
Real signals fail to a known safe state. Your program should have two guards.
- Start-up: on the first scan, force all vehicle lights red and don't walk, hold for a few seconds, then enter state 1. Most platforms give a first-scan bit for this. Never power up straight into green or walk.
- Stall guard: run a watchdog timer for each state. If a state lasts far longer than its preset, something has stopped the sequence. Drop to all red and raise an alarm bit.
Exclude state 1 from the stall guard. Vehicle green can legitimately last for hours when nobody presses the button, so a guard on it would trip in normal use.
This is also the point to be honest about real roads. A classroom PLC gives you sequencing logic. A roadside controller adds independent conflict monitoring that forces a safe state, and it is certified to local rules. If you work on real signals, you work to those rules and not to a tutorial.
Test it like an engineer
A program that runs is not a program that works. Engineers prove it with a factory acceptance test (FAT), a written list of checks with a pass or fail result. The sheet below is short and catches almost every student bug.

Run each check and write the result. When one fails, fix the program and rerun the whole sheet, because a fix to the request latch can break the start-up. Our post on the factory acceptance test checklist shows how the same idea scales to a whole machine.
Run it in a free lab
You can practise this without buying hardware. EDWartens Lab has a pedestrian crossing job in its PLC lab. You read a client brief, write ladder logic, Structured Text or SFC, and watch the lights and cars move in 2D and in 3D. It ends in a numbered FAT that runs automatically. Lab access is free with a free EDWartens account, it runs in the browser, and it is for learning, not for designing real signals.


If you want a structured path, the PLC Programmer job simulation turns a project like this into a working day at a simulated company, and the free PLC internship runs for 4 weeks in the browser with no hardware. Both are training, not employment, and neither promises a job. If you come from software, our guide from software engineer to controls engineer shows the wider route. For a first project list with real specs, read PLC programming projects for beginners, and for a simulator that costs nothing, see the LADX Mini guide.
Every EDWartens course is free to learn in full. The optional certificate of completion is a one-off US$8.99 for a beginner course, and anyone can check it on the verification page. It is an EDWartens certificate, not a vendor credential.
Practise with us
Internship
PLC Programming
Free internship: 4 weeks, a free certificate and nothing to buy. The Engineer-verified internship adds an engineer's review and the graded certificate.
See the internshipRoles
PLC and automation
Roles that ask for this skill, 177 open in this country now. Free to see and to apply. We are not a recruitment agency.
See rolesTake the free course
FreePLC programming · Beginner · Free
CODESYS and IEC 61131-3 Programming
FreePLC programming · Beginner · Free
OpenPLC: IEC 61131-3 on Arduino, ESP32 and Raspberry Pi
FreePLC programming · Beginner · Free
Siemens TIA Portal in Three Hours
FreePLC programming · Beginner · Free
Allen-Bradley RSLogix 500 and MicroLogix
Questions
How many timers do I need for a PLC traffic light program?
As few as one. A state number plus one timer whose preset changes with the state is the leanest build. One timer per state (six here) is the easiest to read and debug. Pages disagree because both work, so choose by clarity.
How do I make a pedestrian push button request stay on until the crossing runs?
Use a seal-in. The request coil turns on from the button OR its own contact, and is cleared when the walk state starts. Then a very short press is remembered and the crossing is still served in its turn.
What are the states of a pedestrian crossing sequence, and how long is each?
Vehicle green, vehicle amber, all red, walk, pedestrian clearance (flashing), then all red again. Our training values are 10 s or more, 3, 2, 7, 12 and 2 seconds. Real timings come from local rules and the crossing width.
Can I write a traffic light program without a real PLC?
Yes. A browser PLC lab, a soft PLC such as CODESYS or OpenPLC, or a vendor simulator runs the same ladder logic with no hardware. EDWartens Lab has a pedestrian crossing job that checks your program with an automatic test.
Is a PLC used to control real traffic lights?
Real roadside signals use certified traffic signal controllers built to local standards, with conflict monitoring that works outside the program. A classroom PLC is a good way to learn sequencing, but it is not a signal controller.
What is the difference between a timer-based and a state-machine traffic light program?
A timer-based program chains one timer per step, each started by the last. A state-machine program holds the current step in a number and drives every output from it. The second is shorter and cannot light two states at once.
Sources
- FHWA Traffic Signal Timing Manual, chapter 5, archived edition (read 23 November 2026)
- Pen Test Partners: Introduction to PLCs and Ladder Logic, 1 June 2020 (read 23 November 2026)
- OpenPLC, open-source IEC 61131-3 stack (read 23 November 2026)
Written by the EDWartens engineering team for general education. Product names are trademarks of their owners; mentioning them does not imply endorsement. Prices and terms of other providers were checked on the date shown and can change.

How to Learn PLC Programming From Zero in 8 Weeks

Virtual PLC Lab: Practise PLC Online in 3D, Free

Ladder Logic Symbols: A Cheat Sheet with Examples

PLC Counters CTU, CTD and CTUD Explained With a Video Demo

OpenPLC on a Raspberry Pi or Arduino: Build a Real PLC on a Hobby Board (Video)

How to Learn PLC Programming for Free, Step by Step