7/Programming
Inputs and Outputs
with Python
At the end of Chapter 6, you did a little bit
of programming with the Raspberry Pi’s
GPIO pins using a shell script. In this chap-
ter, you’re going to learn how to use Python
to do the same thing… and a little more.
As with the shell script, Python will let you
access the GPIO pins with code that reads
and controls the pins automatically.
The advantage that Python has over shell scripting is that Python
code is easier to write and is more readable. There’s also a whole
slew of Python modules that make it easy for you to do some
complex stuff with basic code. See Table 4-2 for a list of a few
modules that might be useful in your projects. Best of all, there’s
a Python ...