From the course: Raspberry Pi Essential Training

Unlock this course with a free trial

Join today to access over 23,200 courses taught by industry experts.

Use Python to control GPIO

Use Python to control GPIO

- [Trainer] The Raspberry Pi can be programmed in several languages, but is most commonly programmed in Scratch or Python. In this video, let's look at the Python program used for the GPIO project. It's very simple, but will give you a good idea of how Python controls the Raspberry Pi GPIO. Python provides two libraries for interface with GPIO, GPIO Zero and Rpi.GPIO. I've chosen the GPIO Zero library because the task is simple and GPIO Zero is easy to work with. Note that only importing classes for LED and a Button. There are lots of other classes for other controls on output devices. One more thing, don't confuse the Python GPIO Zero library with the Raspberry Pi model Zero. They obviously aren't the same thing, but you'll hear them in the same conversation. And if you're not paying attention, it's easy to mistake one for the other. Next in the Python code, we import sleep. This gives us a way to slow down the Python program, so it checks the button only once every second. This…

Contents