Close
0%
0%

Traffic Light Crossing

A dual light based pedestrian traffic crossing with button and sound.
Tones are Australian based, reversed engineered from a recording.

Similar projects worth following
Its been a long time coming (I've had these lights for about a decade) and finally this project is completed!

This is an Arduino based light controller project that uses a single momentary push button to trigger the crossing sequence.

A button push initiates the traffic crossing sequence which cycles through a "wait on red light" to "go on green light" to "don't walk flashing red" to "solid red light".

Sound was added to add authenticity as the lights alone were quite boring. The tones and timings are as close to authentic Australian sounds heard at a real crossing, reversed engineered from a YouTube video recording (not mine, see links).

Summary:

The push button starts the sequence and the Red light is switched on and the idle tone is played. Then the Green light is switched on and the 'chirp' sound plays with the woodpecker sound following that. This continues for 10 seconds and then the Red light starts to flash (don't walk phase) while the idle tone plays in sequence with the flashing. Finally a solid Red light completes the cycle, with a few more idle tones to follow. As I didn't want the idle tone playing indefinitely, the sound stops after three or so times. If there is some demand for a continuous tone loop, then I may add this to the source as a flag.

Circuit:

See the schematic for the basic wiring. I use a 12v PSU for the main DC that runs the lamps connected via the relay modules. A DC-DC convertor is used to bring the voltage down to the Arduino's 5V operational level.

Arduino source:

The source is deliberately simple so as many people as possible could follow along. No classes / objects are used, its just straight procedural C. The major functions are defined for convenience over saving available code space on the device. This makes it super easy in case you need to adjust your relays to active HIGH instead of active LOW. These high level settings are in just one common function per relay, that is shared by the rest of the program.

Details on the sound:

After getting the source audio into the analysis software, there were three distinct sequences that were required. I called these audio functions: playIdle, playChirp and playWoodpecker.

Play Idle uses a 973Hz tone that runs for 25ms, followed by an 1800ms delay in between pulses.

The Chirp sound consists of 11 separate tones, each played for 11ms, totalling 121ms. I calculated 125ms from the spectral analysis so this was close enough. The tones are stored in an array and play in order within a for loop that cycles through each one. 

Play Woodpecker is a fast 500Hz beat. Each tone lasts a very short 30ms, with a delay of 117ms between beats. This lasts a generous 10 seconds, which is frankly a lot longer than most crossings in real life!

The idle tone is used again during the final red flashing sequence and subsequent wait sequence.

  • 1 × Arduino Pro Mini 5v 5v version is better here as the relay modules need 5v to activate
  • 2 × 5v Relay Module Readily available online via ebay etc
  • 1 × Push Button Any normally open switch will do here
  • 1 × 10k ohm resistor Used as a pull up for the button input
  • 1 × Piezo speaker Used to play the tones

View all 7 components

  • ** Project Update!

    ronald08/09/2019 at 05:45 1 comment

    After completing, showing friends and family no one noticed that the person silhouette figures were the mixed up!

    It took the eye of a hacker (after this project being featured on Hack a Day) to notice this.

    Of course I fixed this (rookie) error as soon as practical.

    It must have happened during the cleaning / reassembly of all the light components as years of sitting in the shed had build up quite a bit on gunk.

    The YouTube video won't be updated and hopefully won't confuse those outside of Australia thinking that we have reversed silhouettes in the wild! :)

View project log

  • 1
    Modules, modules, modules!

    I recommend keeping this project at the modular level as follows:

    1) Power module (I use 12v in, 5v out)

    2) CPU module

    3) Button module

    4) Relay module(s)

    For the main lamps, I use the 12v rail wired via a relay so that the lamp receives the full 12v whilst ON. This can be (and probably should be) tested independently from the CPU module.

    The button line is pulled high via the 10K resistor and awaits a momentary push to GND to activate.

    The CPU module is last to wire up, once the Power + Relay + Lamps have been tested separately. As the button is directly coupled to the CPU, it has to be tested together once it is all wired up.

View all instructions

Enjoy this project?

Share

Discussions

klightspeed wrote 08/08/2019 at 08:39 point

The walk and don't walk pictographs in the first photo are reversed - the red lamp has the walk pictograph, and the green lamp has the don't walk pictograph.

  Are you sure? yes | no

Ken Yap wrote 08/05/2019 at 14:04 point

Hahaha, nice. 👍 I'll never understand those people who keep jabbing the button in the belief that this will convey their impatience to the controller. Or maybe they are just expressing their feelings.

  Are you sure? yes | no

ronald wrote 08/05/2019 at 14:06 point

I think we are all probably guilty of pressing it more than once but true! It does nothing at all to speed up the process! :)

Related comic:
https://imgur.com/gallery/mnG4w

  Are you sure? yes | no

Stuart Longland wrote 08/07/2019 at 21:25 point

Guilty as charged… the constant exercising of the button gives me something to do and will ensure the switch is replaced sooner due to wear.

If the traffic light controller is old enough to be relay based, it may also hasten the demise of the controller itself meaning someone will have to program up a new one (maybe with more appropriate timings, thus fixing the root cause in the process).

  Are you sure? yes | no

Ken Yap wrote 08/07/2019 at 21:29 point

😀😉

Though I suspect any controllers that old will be on a controller box spotters' list. 😀

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates