PLC Traffic Light Ladder Logic: How It Works

How-to basics · Updated November 23, 2026

PLC traffic light ladder logic is a program written in the Ladder Diagram language that controls a traffic light sequence—typically green, yellow, red—using timers and output coils. The most common implementation uses three timers (one per light phase) that cascade, so each timer’s done bit triggers the next, creating a repeating cycle.

Background: Why Ladder Logic for Traffic Lights?

Programmable Logic Controllers (PLCs) were originally designed to replace hardwired relay panels in factories. Ladder Logic mimics the electrical relay circuits that technicians already knew, so it became the standard language. Traffic lights are a classic PLC training exercise because they demonstrate timers, sequencing, and state transitions in a simple, visible way. Unlike a microcontroller, a PLC is rugged, designed for industrial environments, and can handle multiple inputs/outputs (I/O) reliably. For a single intersection, a PLC replaces dozens of electromechanical timers and relays, making maintenance easier and allowing quick changes to timing without rewiring.

How Traffic Light Ladder Logic Works

The core idea is a repeating sequence: Green (say 10 seconds) → Yellow (3 seconds) → Red (10 seconds) → back to Green. In ladder logic, you use timer instructions (TON – Timer On-Delay) to create delays. A typical program for one direction (north-south) might look like this:

  1. Rung 1: A normally open contact for a “run” input (e.g., a start switch) energizes a master control relay (MCR) or a seal-in circuit.
  2. Rung 2: The green output (O:0/0) is energized when the sequence is in the green state. This state is controlled by a timer T4:0 that is enabled when the red timer is done.
  3. Rung 3: Timer T4:0 (green duration) is enabled when the green output is on. When T4:0 done bit (T4:0/DN) turns on, it de-energizes green and energizes yellow.
  4. Rung 4: Yellow output (O:0/1) is energized when T4:0/DN is true and T4:1 (yellow timer) is not done.
  5. Rung 5: Timer T4:1 (yellow duration) is enabled when yellow is on. When done, it triggers red.
  6. Rung 6: Red output (O:0/2) is energized when T4:1/DN is true and T4:2 (red timer) is not done.
  7. Rung 7: Timer T4:2 (red duration) is enabled when red is on. When done, it resets the sequence by turning off red and turning on green again (often using a reset coil on the timers).

In practice, you need a second sequence for the cross street (east-west) that is offset by half a cycle. For example, when north-south is green, east-west is red. This is done by using the same timers but inverting the outputs with normally closed contacts.

Here is a simple example for a two-light intersection (one direction only, for clarity) using Allen-Bradley style addressing:

|----[Start]----[Stop]----(Run)---|
|----[Run]----[T4:2/DN]----(T4:0 EN)---|
|----[T4:0/DN]----(T4:1 EN)---|
|----[T4:1/DN]----(T4:2 EN)---|
|----[Run]----[T4:0/DN]----[T4:1/DN]----(Green O:0/0)---|
|----[T4:0/DN]----[T4:1/DN]----(Yellow O:0/1)---|
|----[T4:1/DN]----[T4:2/DN]----(Red O:0/2)---|

Note: The above is a simplified representation; a real program would include interlocking to prevent green and red on at the same time, and a reset for timers.

Choosing Timer Values and Sequence

Timer values are set in the PLC’s data table (e.g., T4:0.PRE = 100 for 10 seconds if the time base is 0.1 sec). Typical traffic light timings for a small intersection:

  • Green: 10–20 seconds (depending on traffic volume)
  • Yellow: 3–5 seconds (based on approach speed)
  • Red: 10–20 seconds (matching the other direction’s green + yellow)

For a four-way intersection, you need two sequences: Main road (N-S) and side road (E-W). The side road’s green starts when the main road’s red starts. You can achieve this by using the main road’s red timer to enable the side road’s green timer.

Common Problems and Misconceptions

One common mistake is not resetting timers, causing the sequence to skip or hang. Another is forgetting to add a “master reset” that turns off all outputs when the PLC is in test mode. A frequent misconception is that you need a separate timer for each light; actually, you only need one timer per phase, and you can derive the other direction’s lights from the same timers using logic.

Another issue is “race conditions” where two timers finish at the same scan, causing both green and red to be on momentarily. To prevent this, use interlocking contacts (normally closed) on the opposite outputs. For example, the red output rung includes a normally closed contact of the green output.

Comparison: Ladder Logic vs. Other PLC Languages

Ladder Logic is not the only way to program a traffic light. Structured Text (ST) uses IF-THEN-ELSE statements and is more compact for complex sequences. Function Block Diagram (FBD) uses graphical blocks and is good for PID loops. Sequential Function Chart (SFC) is designed for state machines, which traffic lights essentially are. However, Ladder Logic remains the most widely used because it is intuitive for electricians and maintenance staff, and it is the default language in most PLCs. For a simple traffic light, Ladder Logic is often the fastest to write and debug.

Cost and Implementation Considerations

The cost of a PLC-based traffic light controller varies widely. A small PLC (e.g., a MicroLogix or a Siemens S7-1200) costs $200–$500, plus I/O modules if needed. For a real intersection, you also need power supplies, relays, contactors, and the traffic light heads themselves. However, for training or simulation, you can use free software like LogixPro or Siemens PLCSIM. Many universities and technical schools use traffic light simulations as a lab exercise because they require minimal hardware—just a PLC and a few lights or LEDs.

Safety and Real-World Considerations

In real traffic signals, safety is critical. You must implement fail-safe logic: if the PLC loses power or a timer fails, the lights should default to a flashing red (or a known safe state). This is often done with a watchdog timer (a timer that must be reset periodically; if it times out, the PLC goes to a safe state). Also, you must never have green in both directions simultaneously—use hardware interlocking relays in addition to software interlocks. In many jurisdictions, traffic light controllers must meet specific standards (e.g., NEMA TS-1 in the US). For a hobby or educational project, always use low-voltage DC (e.g., 24V) and avoid direct mains connection.

Frequently Asked Questions

Can I use a PLC to control a real traffic light?

Yes, but you must use proper rated outputs (e.g., relay outputs) and ensure the PLC is housed in a weatherproof enclosure. Real traffic lights use 120VAC or 240VAC, so you need interposing relays or solid-state relays to switch the load. Also, you must comply with local traffic regulations and safety standards.

How do I add a pedestrian crossing to the ladder logic?

Add a pushbutton input that, when pressed, requests a walk signal. In the ladder logic, you can use a latch to remember the request, then when the current green phase ends, insert a walk phase (e.g., 5 seconds) before the next green. This requires an extra timer and some extra rungs.

What is the difference between TON and TOF timers in this context?

TON (Timer On-Delay) turns on its done bit after the preset time while the input is true. TOF (Timer Off-Delay) turns on its done bit immediately when the input turns on, then turns off after the preset time when the input turns off. For traffic lights, you typically use TON because you want the output to stay on for a fixed duration after an event.

Why does my ladder logic sometimes show both green and red on?

This usually happens because you didn’t add interlocking contacts. For example, if the green output rung has a normally open contact of the red timer, and the red output rung has a normally open contact of the green timer, you get a conflict. Instead, use normally closed contacts of the opposite output in each rung to ensure mutual exclusion.

Can I simulate traffic light logic without a physical PLC?

Yes, many PLC vendors offer simulation software. For Allen-Bradley, you can use RSLogix/Studio 5000 with an emulator. For Siemens, PLCSIM works with TIA Portal. There are also free online simulators like PLC Fiddle, but they may not support all timer functions.

How do I make the sequence start over automatically?

When the last timer (red) finishes, its done bit should reset the first timer (green) and also reset itself. In ladder logic, you can use a reset instruction (RES) on the timers, or use a normally closed contact of the red timer to enable the green timer. The key is to ensure that after the red timer finishes, the green timer becomes enabled again.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.