Operation Manual

At this point, nothing will happen. Thats perfectly normal: by default, the Raspberry Pis GPIO pins are switched off. If you
want to check your circuit immediately, move the wire from Pin 11 to Pin 1 to make the LED light up. Be careful not to connect
it to Pin 2, though: a current-limiting resistor suitable for a 3.3 V power supply will be inadequate to protect the LED when
connected to 5 V. Remember to move the wire back to Pin 11 before continuing.
To make the LED do something useful, start a new Python project. As with the projects in Chapter 11,An Introduction to
Python, you can use a plain text editor or the IDLE software included in the recommended Debian distribution for this project
as well.
Before you can use the GPIO library you installed earlier in this chapter, youll need to import it into your Python project.
Accordingly, start the file with the following line:
import RPi.GPIO as GPIO
Remember that Python is case-sensitive, so be sure to type RPi.GPIO exactly as it appears. To allow Python to understand the
concept of time (in other words, to make the LED blink, rather than just turning it on and off), youll also need to import the time
module. Add the following line to the project:
import time
With the libraries imported, its time to address the GPIO ports. The GPIO library makes it easy to address the general-purpose
ports through the instructions GPIO.output and GPIO.input, but before you can use them, youll need to initialise the pins as
either inputs or outputs. In this example, Pin 11 is an output, so add the following line to the project:
GPIO.setup(11, GPIO.OUT)
This tells the GPIO library that Pin 11 on the Raspberry Pis GPIO port should be set up as an output. If you were controlling
additional devices, you could add more GPIO.setup lines into the project. For now, however, one will suffice.
With the pin configured as an output, you can switch its 3.3 V supply on and off in a simple demonstration of binary logic. The
instruction GPIO.output(11, True) will turn the pin on, while GPIO.output(11, False) switches it off again. The pin will
remember its last state, so if you only give the command to turn the pin on and then exit your Python program, the pin will remain
on until told otherwise.
Although you could just add GPIO.output(11, True) to the Python project to switch the pin on, its more interesting to make