I've been working on a new Python library that provides a simple interface to everyday GPIO components. It sits on top of the standard RPi.GPIO but requires much less code to get going. It's called GPIO Zero.
Simple example:
I'm aiming for minimal boilerplate (no setmode, setwarnings), easy to read, guessable and obvious.
Code: Select all
from gpiozero import LED, Button led = LED(2) button = Button(3) button.when_pressed = led.on button.when_released = led.off
I've released a public beta and I plan to do a full release within a month. I'd like to get some feedback, particularly from teachers, to help get the language of the interface right (function names and such), and look at some simple and complex examples to see if it's achieving its goals.
Install it on your Pi with:
The library supports Python 3 and Python 2. Python 3 is recommended!
Code: Select all
sudo apt-get update sudo apt-get install python-pip python3-pip sudo pip install gpiozero sudo pip-3.2 install gpiozero
Just open IDLE or a Python shell, import the bits you're using and get going. Full documentation is available at
Please feel free to leave feedback here or in the Google Doc: ... edit?pli=1#