The Raspberry Pi allows you to build hardware projects to interact with the real world but to do this you need to know electronics. This video shows how to use a 555 timer chip and a few other cheap components to make an LED flash. What has this to do with the Raspberry Pi? Not only do you learn about chips, capacitors, LEDs and resistors in this tutorial but also how to generate a timed digital output – handy for all sorts of Pi projects.
- Solderless Breadboard
- 9v battery and clip
- 555 timer
- 100uF Capacitor
- 0.01uf Capacitor
- 220 Ohm resistor (for LED)
- 4.7k resistor (for pins 6/7)
- 200-4.7 resistor (to control speed of flashing)
(all these parts are included in the bitsbox.co.uk electronics starter kit)
Also mentioned: Electrodroid.
The Raspberry Pi was designed to be a starting point for all sorts of exploration. The only problem with having such a wide range of possible uses is that taking advantage of specific aspects of the design can be quite hard. The Pi comes with GPIO (General Purpose Input Output) pins that allow software running on the Pi to detect, respond to and control aspects of the real world. For example, you can attach a digital thermometer chip to the GPIO, detect the temperature and use it to switch on the central heating or text a warning. This is all very well but these GPIO pins are difficult for beginners to use and, crucially, if you mess up your project, you could easily fry your Pi.
Since its release in February 2012, a number of expansion boards have been created to solve this problem (although, in many cases, they do nothing more than make the GPIO pins more accessible rather than providing protection). My favourite is the PiFace.
Developed primarily to help school-children and students use the Pi to learn about programming and electronics, the PiFace, naturally, has protection of the Raspberry Pi very high on its agenda with all inputs and outputs protected. The PiFace is simply slid onto the GPIO pins and adds only a couple of centimetres to the combined height of the two units.
The PiFace has 8 inputs (see photo). You’ll notice that there are actually 9 screw terminals. This is because the last of them is a connection to ground. The inputs are primarily intended to detect the closing of a circuit such as a switch. Imagine you had an LED on your breadboard (with a resistor). The negative pin of the LED would be connected to the ninth screw terminal and the positive to one of the others (say, pin 1) with a switch in between. When the switch is pressed, current will flow into pin 1 and be detected. You can write a simple Python program to detect this.
The PiFace also has 8 outputs. Again, there are 9 terminals because the ninth supplies 5V. The outputs work like the inputs in reverse – if we connected the positive pin of the LED to the 5V terminal and the negative pin to, say pin 1, then we can activate pin 1 in Python which opens the circuit and allows current to flow (and the LED to light). This represents a fundamental difference between the PiFace and the Arduino – in the latter case the digital outputs simply send 5 volts whereas the PiFace outputs are “open collectors” which means they detect when a circuit is completed. The downside of this is that it can make controlling components that are activated by, say, 5 volts, more difficult.
Relays are switches. They’re mechanical devices (you can hear them click on and off) and are ideal for switching on and off external devices. If you wanted to be able to control a motorised toy, for example, you could turn it on and off by cutting the power wire from the toy’s battery and screwing both ends of the wire into two of the relay’s terminals. You could then use a single Python command to flip the relay, connecting the wires and setting off the toy.
The PiFace also includes a power input block which allows you to power both it and the Raspberry Pi from a single 5v input, making it simpler to add mobile power, for example.
Overall, the PiFace is an excellent first I/O board. The forthcoming launch of a connector that will allow you to stack multiple PiFaces will increase its usefulness (you’d be amazed at how quickly you can use up the Inputs and Outputs!). It’s a little on the expensive side (£20) given that this is as much as the cost of a Raspberry Pi Model A but, overall, well worth it.