User Guide

159
The GPIO pins are rated for 3.3 V. They are not 5 V tolerant and
so applying more than 3.3 V to an input pin can break the Pi.
7.4 Basic Output
Blinking an LED is the electronics equivalent of the “Hello,
World!” program. In this example, you will:
1. Make a circuit using an LED and 270 Ω resistor.
2. Learn how to set a GPIO pin to an output.
3. Turn the LED on and off from a terminal window,
and from a Python script.
LEDs must be placed in a circuit in the correct direction as
electricity only flows one way through them. One leg of an LED
is longer than the other – this is called the “anode” and it is the
one that receives power. The other leg is called the “cathode”,
and this the output leg. In Figure 4 you can also see that on the
anode side, the piece of metal inside the LED is smaller.
Figure 4. Light-emitting diodes (LEDs)
It does not matter in which direction you place the resistor.
Unplug the Pi, and then build the circuit in Figure 5. If you do not
have a 270 Ω resistor, then you can use a resistor of a slightly
greater value. Try to avoid using smaller value resistors – if there
40 GPIO21 Input/output.
GPIO0 and GPIO1 do not appear in this pinout. These functions
are shared with the ID_SC and ID_SD pins, which must only be
connected to a special identification EEPROM. Do not use them.
Pin # Name Description