Chapter 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 chapter, 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 module called RPi.GPIO ...

Get Getting Started With Raspberry Pi, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.