Clock-Driven Crossing Lights
Railroad crossing lights using clock and NOT gate. Learn about timing circuits and alternating outputs. Introduction to sequential timing.
What You'll Learn
- Drive a sequential pattern with a clock signal.
- Use a toggle flip-flop to alternate between two states.
- Connect Q and ¬Q outputs to drive complementary output lights.
- Recognize that the output frequency is half the clock frequency.
- Understand the simplest pattern of synchronous sequential logic.
How It Works
A clock-driven crossing lights circuit demonstrates how a clock signal can drive a simple alternating output sequence. The classic application: railroad crossing lights that alternate between two LEDs while a train approaches.
The core mechanism is a clock + flip-flop in toggle mode: each clock edge flips a stored bit, and the bit (and its complement) drive two output lights. Result: lights alternate at half the clock frequency.
For a more dramatic effect, two flip-flops in toggle mode produce a 4-state sequence; combinational logic on the two outputs decodes which lights to illuminate at each phase. With four states you can do pattern A-B-A-B (alternation) or A-AB-B-AB (four phases), depending on how the outputs are decoded.
This is the simplest possible synchronous sequential circuit — state changes only on clock edges, the state determines the output, and the output is observable as a deterministic time-varying pattern. It's the seed of finite-state machines and clocked control logic.
Try It Step-by-Step
Set the inputs in the embed above, then read what should happen and confirm.
- 1Clock = running at 1 HzExpected:
Lights alternate at 0.5 HzWhat you'll see: The two lights swap on every clock edge — one on, one off. Each light's frequency is half the clock's. - 2Clock = stoppedExpected:
Lights frozenWhat you'll see: Stop the clock — pattern freezes wherever it is. Sequential circuits need a clock to evolve. - 3Clock = running at 10 HzExpected:
Faster alternation, 5 Hz visibleWhat you'll see: Increase the clock frequency — the lights blink faster. The relationship is exactly clock_freq / 2. - 4Clock = single edgeExpected:
Lights swap onceWhat you'll see: A single clock pulse produces a single state transition. Sequential logic responds to edges, not levels.
Components Used
Real-World Applications
Real railroad crossing lights. Modern crossings use microcontroller-driven LED arrays, but the alternating-light behaviour is exactly what this circuit demonstrates.
Construction-site warning lights. Yellow flashers on barriers alternate at a fixed rate — same clock-divided toggle pattern.
Heartbeat / activity LEDs. A microcontroller's activity LED blinks at a fixed rate to confirm the system is alive — implemented as a counter divided down to a slow clock.
PWM-driven LED brightness. A clock divides the system clock down to a PWM frequency that controls duty cycle for analog-style brightness — same clock-divider principle.
Synchronous traffic light controllers. Real traffic lights use FSMs clocked at 1 Hz or so; the alternating crossing-light pattern is a one-state FSM specialization.