Showing service states on a traffic light

When I was about fifteen, I was an inveterate thief of temporary street furniture – no, I have no idea why. Hormones are funny things. Just in case anyone from Mid Beds County Council happens to be reading, I am very, very sorry. There were several bollards in my bedroom, a cat’s eye which my uncle (possibly while under the influence) had liberated from a street in the dead of night, and a no parking sign on the wardrobe door.

I never had a traffic light.

Raspberry Pi hooked up to a traffic light

♪ ♫ I like traffic lights, although my name’s not Bamber.

Magnus Lubeck has a traffic light (which he acquired through legal means), and he’s been using it – powered by a Raspberry Pi, of course – in place of a big display screen in his office for monitoring service states using Nagios/op5. Here’s some video.

There’s much more on Magnus’s blog, along with circuit diagrams and code, which you can use yourself if you happen to somehow come into possession of your own traffic light. He mentions the first application like this he ever saw, where a pub toilet lock was hooked up to a traffic light so you didn’t have to check whether there was someone in there or not. I’ve been thinking of ideas for this application from visual kitchen timers, to free parking space detectors, to instant message notifiers; although I feel it’s probably best not to get into the habit of using street furniture as interior decoration again. Add your own ideas below!



ukscone avatar

the amber roadworks lights were the best. the batteries inside were great for powering all sorts of things

liz avatar


*Nonchalant humming*

ukscone avatar

walk away slowly there is nothing to see here

Andy avatar

Late one Saturday night, I got to wondering what made them flash.
Fifty years on, if I need a simple oscillator, I still use that circuit.

Jongoleur avatar

You mean you don’t remember the oil-fired ones?


(I’ve got an LNWR Trespassers gate sign…)

M.V. Wesstein avatar

For anyone wishing to do this themselves, please mind that you’re working with Mains power, so either know what you’re doing or ask advise from someone who does! Anyone under 16: you need adult supervision! Period!

liz avatar

Indeed; Magnus makes that point very clearly in the instructions on his blog.

ukscone avatar

i’m currently in negotiation with a friend who has contacts in his towns DOT to see if they have any traffic lights they aren’t using. i’ve even offered to save him the cost of a workcrew by saying i’ll remove it from the pole myself

Joules avatar

I have a pipe cutter…. Angle grinder at night is a dead giveaway.

Ian avatar

Usually they would be using that trafficlight if such a light was mounted, and you may not want to try and remove one on your own…

mittfh avatar

Not entirely related, but it’s possible this blog post marks a milestone (of sorts), given the URL ID is 2000…

Joules avatar

You can also change the masks in some of these lights, so you could use it to indicate No mail, system XXXX or mail waiting.

paulie avatar

Does anyone else remember a website called ” Traffic Light Wars” ?
A never-ending vicious battle between the red man and green man…

One of the Amateur Radio shops here in the UK had an “ON AIR” red studio light for their smallest room….

Wombat avatar

WOT no saftey tip about NOT setting up said lights on a road!

liz avatar

No. I haven’t added one about not lifting them with a bent back, and watching your fingers near snips and solder, either. ;)

Matt Hawkins avatar

The amber roadwork lights were cool … unless they were the ones bolted to the safety barrier. Much harder to swipe from a moving car while hanging out the window*

* – a story told to me by someone, via a third party, who has since moved to Ecuador

Charles "onlyLinuxLovesUBack" avatar

I’m going to have to rate this a thumbs down.
If he used gnu/linux to talk to the pi it would have got the up.

Alan Williams avatar

If you drive relays with transistors this way you really should have a reverse biased protection diode across the relay coil to supress the back emf spike that could destroy your transistor or other things on your 12v line when you turn the relay OFF.

A 1N4001 or 1N4148 ought to do it.

Here are a couple of references on it.

darkcity avatar

I’ve been looking at a similar project. My main concern is how well halogen lamps respond to being switched a lot and how quickly they can be switched.

Alan Williams avatar

I think some kind of soft start would help with lamp life. That will be different for 240v ac as opposed to say 12v dc. With the DC solution you would need to watch the heat dissipation of your switch (transistor or MOSFET etc) when it’s not fully conducting and the lamp filament is cold. The maximum frequency at which you can turn them on and off is going to be the sum of the soft start period and the filament cool down period. I read somewhere that some old traffic light systems are 12V and use car head light bulbs, based on that you can expect a large number of on off cycles if you do it gently. If you do it with DC you are likely to have high currents and if you do it with AC high voltage. A 50W globe at 12v draws 4A steady state, but as I said earlier it’s the cold filament inrush current that you need to be careful to consider as it will be much higher. Go carefully with either.

M.V. Wesstein avatar

Cue LED lights, pre-coloured too ;-)

darkcity avatar

Thank you for the detailed answer, it will help me with the design.

Urban Svensson avatar

Sweet! Seems you are up to speed on your “bastel” activities (or if you prefer “brico” activities). I’ll obviously need to try to do something along these lines myself.

nihilant avatar

we did this already at the haxogreen hacker camp in luxembourg:


Nick Bridge avatar

I love the Monty Python reference! I still sing that song…

Ian avatar

Gale Cengage used a traffic light to monitor uptime, however the project has been discontinued. This isn’t on their website, BTW.

Steve Perkins avatar

My team built our own stoplight and used it to show the current build state. Red was a broken build, yellow was a build in progress, and green was (of course) build success.

There’s a lot more detail, photos, and a video at

Roger Wolff avatar

If you don’t like the breadboarding part of this project, you can get the spi_relay board , together with a rpi_serial and a cable. All plug and play.

From there you can control lamps, traffic lights, whatever you want!

(You can also chose the I2C version, same story, different cable).

M avatar

As total electronics n00b I just need a specific list of components and how to put them together. The code and stuff is not a huge challenge for me but the electronics and shematics are. So if anyone can help me with that …

George OIphin avatar

Where Abouts In Mid-Beds?

Comments are closed