Before we even get started with the GPIO, lets make an LED light up by simply wiring it to the +3.3v supply and 0v.
So… We have a yellow wire from the Pi’s +3.3v supply to the breadboard and this connects to an LED then via a 270Ω (ohm) resistor to 0v. The green wire connects back to the Pi.
(Note that here and in the following pages, the Fritzing breadboard layout is slightly different from the photos – it’s the same circuit, just laid out in a way that makes it easy to see in the images)
Refer to the diagram here to work out the pins we’re using. From this view the 3.3v pin on the GPIO connector is to the top-left, or pin number 1 on the connector.
In electronics terms, our circuit diagram looks like this:
A quick word about the electronics involved. LEDs are Light Emitting Diodes and the diode part is important for us – they only pass electricity one way, so we need to make sure we put them in the right way round. They have a long leg and a slightly shorter leg. The long leg goes to the plus side and the shorter leg to the negative (or 0v) side. If we’re cut the legs short (as I have done here), then another way is to look at the side of the LED – there will be a flat section. Think of the flat as a minus sign and connect that to the 0v side of the circuit.
If we allow too much current through the LED, it will burn very bright for a very short period of time before it burns out, so we need a resistor to limit the current. Calculating the resistor value is not difficult but for now, just use anything from 270Ω to 330Ω. Anything higher will make the LED dimmer.
So now we have a lit LED. What we really need to do is make it easily turn on and offable – preferably by a command or program running on the Raspberry Pi.
We need to move the yellow wire to one of the programmable GPIO pins. We’ll move it to wiringPi pin 0 (GPIO-17) which is notionally the first user GPIO pin. (It’s physical location is pin 11 on the GPIO connector)
For more detail: 1: A single LED