PLC TRAFFIC LIGHT PROJECT

PLC Traffic Light Ladder Logic With a Pedestrian Crossing

A correct PLC traffic light with a pedestrian button: the state table, one-timer and six-timer builds, a request that is never lost, and a test sheet to prove it.

By EDWartens engineering team 23 November 2026 Updated 23 November 2026 9 min
PLC Traffic Light Ladder Logic With a Pedestrian Crossing

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.

StateVehicle lightsPedestrian lightsTraining timeReference
1 Vehicle greenGreenDon't walk10 s minimum, then waits for a requestOur choice
2 Vehicle amberAmberDon't walk3 sFHWA: about 3 to 6 s, 3.0 s at 25 mph
3 All redRedDon't walk2 sFHWA: red clearance should not exceed 6 s
4 WalkRedWalk7 sFHWA: MUTCD minimum walk 7 s (4 s at low pedestrian volume)
5 Pedestrian clearanceRedFlashing don't walk12 sCrossing distance divided by walking speed
6 All redRedDon't walk2 sOur 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.

Crossing states and training timings
Crossing states and training timings

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.

TimerStarts whenPresetDone bit moves to
T_MINGREENVehicle green begins10 sWait for the request
T_AMBERRequest is present and min green is done3 sAll red
T_RED1Amber done2 sWalk
T_WALKRed1 done7 sClearance
T_CLEARWalk done12 sAll red 2
T_RED2Clearance done2 sVehicle 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.

“PLC Traffic Lights Ladder Diagram - Learning PLC Programming” by Instrumentation Tools, 10 min. Played from the creator's own YouTube channel; the video belongs to them.

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.

  1. The state can only have one value, so two lights cannot be on from different steps.
  2. Changing a time means changing one number in one table.
  3. 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.

RungConditionAction
1Button OR request contact, AND NOT (state 4 or state 5)Request coil on
2Request AND state 1 AND min green doneAllow the move to amber
3State 4 beginsClear 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.

From brief to running program
From brief to running program

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.

Test sheet for your crossing program
Test sheet for your crossing program

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.

Pedestrian crossing model in the 3D hall with traffic lights, cars on a road strip and a control cabinet
The pedestrian crossing job in the lab's 3D hall: lights, cars and the control cabinet.
PLC lab with the ladder editor showing energised green rungs beside the live PLC simulator and the I/O list
Ladder logic running in the PLC lab, beside the simulator and the I/O list.

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 internship

Lab

PLC lab

Practise in your browser. Free, nothing to install.

Open the lab (opens in a new tab)

Roles

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 roles

Take the free course

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

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.