What you will need:
- Raspberry Pi
- 1 Light Emitting Diode (LED)
- 1 220Ω to 330Ω Resistor —[III I]—
- 2 Female to Male Jumper Wires
Before we begin delving too deeply into the Raspberry Pi and physical computing, I wanted to begin with the very first experience my son and I had with attaching something to the Raspberry Pi’s General Purpose Input and Output (GPIO) port. There is no programming involved for this project and it was simply a way to show my son how easy it is to use a computer to illuminate a Light Emitting Diode (LED).
It is important to ensure that the Raspberry Pi is shut down and disconnected from power before attaching anything to its GPIO pins. It is possible to damage the Pi if everything isn’t checked and double-checked before power is applied.
By referencing the breadboard diagram above, you can see a very simple circuit. We began by attaching a yellow female-to-male jumper wire to pin #1 (+3.3v) of our Raspberry Pi B+ and the other end to a socket on our breadboard. The positive side of our LED is attached to the same row as the yellow wire and the negative side is attached to another breadboard socket.
The program I used to create the breadboard diagram above is a free open-source program called Fritzing and you will notice that the breadboard sockets that are connected together are slightly highlighted in green. This is a great feature of the software that really helps make sure everything is connected correctly.
Next, we attached a 220Ω resistor from the same row as the negative lead of the LED to another socket. Finally, we attached a green female-to-male jumper wire from the resistor’s row to pin #3 (GND) of the Raspberry Pi.
It is important to note that Light Emitting Diodes (LEDs) only pass electricity in one direction so we need to make sure we put them in the breadboard correctly. The LED has a long leg (Anode) and a slightly shorter leg (Cathode). The long leg goes to the plus side and the shorter leg to the negative (or 0v) side. The LED will also have a flat side that helps indicate its negative leg.
If we allow too much current through an LED, it will burn very brightly for a short period of time before it burns out. Therefore, we need to utilize a resistor to limit the current. For this particular example, use anything from 220Ω to 330Ω. Anything greater in value will make the LED dimmer.
Once the Raspberry Pi is powered up, the LED will be lit. Obviously this project is extremely simplistic and really only utilizes the Raspberry Pi as a power supply to light the LED. However, this is a really nice way to become comfortable with the Raspberry Pi GPIO and attaching electronic components to a breadboard. Our next project will incorporate some Python code to make things a bit more interesting.