mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-12-08 20:39:01 +00:00
Big push on getting the docs cleaned up before 1.0. Proper wrapping of everything so it's decently viewable from the command line (or as decently viewable as markdown can be - the tables will never look great from the command line). Only one code change in this PR: rename bouncetime to bounce_time (everything else is PEP-8, so this probably should be too) and change its units to seconds from milliseconds (again, all other durations in the library are in seconds, so it feels inconsistent that this one isn't; for the sake of those who won't read the docs - which is most people - I figure consistency helps with guessing!).
83 lines
1.8 KiB
Markdown
83 lines
1.8 KiB
Markdown
# GPIO Zero
|
|
|
|
A simple interface to everyday GPIO components used with Raspberry Pi
|
|
|
|
## Latest release
|
|
|
|
The latest release is **v0.6.0 beta 1** released on 28th September 2015.
|
|
|
|
## Motivation
|
|
|
|
The "hello world" program in Java is at least 5 lines long, and contains 11
|
|
jargon words which are to be ignored. The "hello world" program in Python is
|
|
one simple line. However, the "hello world" of physical computing in Python
|
|
(flashing an LED) is similar to the Java program.
|
|
|
|
6 lines of code to flash an LED. And skipping over why `GPIO` is used twice in
|
|
the first line; what `BCM` means; why set warnings to False; and so on. Young
|
|
children and beginners shouldn't need to sit and copy out several lines of text
|
|
they're told to ignore. They should be able to read their code and understand
|
|
what it means. This module provides a simple interface to everyday components.
|
|
The LED example becomes:
|
|
|
|
```python
|
|
from gpiozero import LED
|
|
|
|
red = LED(2)
|
|
|
|
red.on()
|
|
```
|
|
|
|
Any guesses how to turn it off?
|
|
|
|
## Install
|
|
|
|
Install with pip:
|
|
|
|
```bash
|
|
sudo apt-get install python-pip python3-pip
|
|
sudo pip install gpiozero
|
|
sudo pip-3.2 install gpiozero
|
|
```
|
|
|
|
Both Python 3 and Python 2 are supported. Python 3 is recommended!
|
|
|
|
### Upgrade
|
|
|
|
Upgrade to the latest version with:
|
|
|
|
```bash
|
|
sudo pip install gpiozero --upgrade
|
|
sudo pip-3.2 install gpiozero --upgrade
|
|
```
|
|
|
|
## What's included?
|
|
|
|
Components:
|
|
|
|
- LED
|
|
- Buzzer
|
|
- Button
|
|
- Motion Sensor
|
|
- Light Sensor
|
|
- Temperature Sensor
|
|
- Motor
|
|
|
|
Boards & accessories:
|
|
|
|
- LED Board
|
|
- Traffic Lights
|
|
- PiLITEr
|
|
- PI-TRAFFIC
|
|
- Fish Dish
|
|
- Traffic HAT
|
|
|
|
## Getting started
|
|
|
|
See the [input devices](inputs.md) and [output devices](outputs.md) to get
|
|
started. Also see the [boards & accessories](boards.md) page for examples of
|
|
using the included accessories.
|
|
|
|
For common programs using multiple components together, see the
|
|
[recipes](recipes.md) page.
|