The project replicates the operation of a Puffin crossing. There are RED-AMBER-GREEN lights for the road traffic and RED-GREEN lights for the pedestrians on the kerbside.
It uses the raspberrry Pi computer, the Piface add on board and some electronic components.
The Puffin crossing dispenses with the flashing phase of the Pelican crossing and adds a sensor that detects pedestrians crossing the road and waits for them to finish crossing before changing the lights. The drawing below shows the traffic light sequence and the process as a flowchart.
The diagram below shows the code that needs to be entered in Scratch or in Python to make the sequence work correctly. The two sets of code can be downloaded by using the link given in the Resources appendix at the end of this document.
For more information on programming in scratch visit scratch.mit.edu
The Scratch version of the code uses the PiFace board connected to a breadboard.
The Python version of the code does not use the PiFace board but connects directly to the Raspberry Pi using a ‘Cobbler’ cable connected to a breadboard
The diagram below shows the schematic diagram of the LED wiring.
There are five each of:
• Transistors – Circles with three connections each
• Light Emitting Diodes (LEDs) – A triangle with a line crossing the apex
• Resistors – Rectangular hollow shapes
The transistors are actually inside the PiFace board so these do not need to be wired in. Notice that the LEDS all connect on one end so only one wire is needed for that part of the wiring. When building a circuit like this it is usual to use a Breadboard.
A breadboard consists of a number of electrical contacts that are connected to each other in groups and set inside a plastic shell. Components are pushed into the breadboard to make experimental and prototype circuits. Using a breadboard means that there is no need to use soldering irons and also it is easy to change the circuit layout.
The drawing on the next page show a breadboard in use for this project
Basic Breadboard Showing some INTERNAL connections
PiFace version Connection Diagram Photograph of Wired System with PiFace
The parts list below includes items that are available from a variety of suppliers. To make it easier we have included the Maplin part numbers as there is probably a Maplin store near to you.
Raspberry Pi A complete Kit that contains many of the required peripherals to be able to use the Raspberry Pi
Resistors 220 Ohm resistors. You may need different values if you change the LEDs
LEDs Mixed bag of LEDS, contains Red, Yellow and Green LEDs
Breadboard Breadboards come in various sizes. This one can easily support the Pedestrian Crossing Project
Hookup Wire Pack of short lengths of wire in different colours
Note. The PiFace Board is available from Farnell in the UK: uk.farnell.com/raspberry-pi
The PiFace board uses a modified version of the standard Raspberry Pi image. You can download it from here: pi.cs.man.ac.uk/download
More information on the PiFace board is here: tinyurl.com/pifacedocs
The Scratch & Python code used in the project is available here:
A video showing the sequence working is here:
Raspberry Pi GPIO