User Tools

Site Tools


traffic_lights_raspi

Traffic lights with pedestrian switch

Using a raspberry pi and almost pure bash script, not python 8-)

What you'll need

The products listed here are mostly ref links from Amazon. If you find the info on this page useful, do me a favour and use these links for purchase.

  1. Raspberry Pi (any revision will do, the RPI0W will require soldering tho)
  2. A good SD card (4 or 8GB will be fine too)
  3. A decent power supply
  4. Breadboards (we'll use one 170 tie points breadboard for this)
  5. Some sort of electronic 'basic kit' like this one

Thats about it. I've added a mini wifi dongle into the setup for ease of use and heatsinks for a lower temperature of the chips.

What we'll do

The idea is to build 'half' of a normal traffic light that you might find right in front of your house. The traffic lights will have 3 colors (red, yellow and green) while the pedestrian lights will only have red and green. There will be a button for pedestrians to request a red light phase for traffic, enabling them to cross. Because it could be doubled to resemble a real setup by just 'mirroring LEDs and resistors through appropriate wiring' anyways, we'll only build one set of traffic lights plus one button.

The end product will look a bit like this:

You can see 5 LEDs (2 red, 1 yellow, 2 green), 5×330 Ohm resistors, one button and a lot of jumper wires, which will be explained later on. Note that setting up the raspberry pi is beyond the scope of this tutorial, only the packages needed for this very thing are mentioned.

Preparations

Get the necessary parts ready. These are:

  • 5x resistors 330Ω (anything between 270Ω and 330Ω will be fine)
  • 2x green LED
  • 1x yellow LED
  • 2x red LED
  • 1x pushbutton
  • 7x jumper wire, male/female
  • 7x jumper wire, male/male

Install the wiringPI package:

# apt-get install wiringpi

traffic_lights_raspi.txt · Last modified: 2017/06/19 14:47 by flo