Sample recipes of gpiozero, a simple interface to GPIO devices with Raspberry Pi.
Number | File Name | Description | Wiring | Circuit | GPIO |
---|---|---|---|---|---|
1 | 01-LED-blinky-01.py | LED blinky. | --> | 23 | |
2 | 02-hello-button-01.py | Push the button to say hello. |
--> | 24 | |
3 | 03-LED-button-01.py | Push the button to turn the LED on. |
--> | 23,24 | |
4 | 04-PWM-LED-01.py | LED brightness control with PWM, or Pulse Witdh Modulation. | --> | 23 | |
5 | 05-servo-01.py | Turn the servo moter. | --> | 17 | |
6 | 06-light-sensor-01.py | Say when it's light or dark. | --> | 11 | |
7 | 07-distance-sensor-01.py | Supersonic distance sensor. | --> | 23,24 | |
8 | 07-distance-sensor-02.py | Supersonic distance sensor and 4-digit 7-segment LED display. | --> | 20,21,23,24 | |
9 | 08-motion-sensor-01.py | PIR (Passive Infrared Ray) motion sensor. | --> | 4 | |
Number | File Name | Description | Wiring | Circuit | GPIO |
- Clone the code down to you computer.
- Go into the working directory.
- Make the circuits with circuit diagrams made with Fritzing.
- Run the code by Python.
- Enjoy coding, hacking, and tinkering!
$ cd Documents
$ cd Python\ Projects
$ git clone paste-the-URL-from-the-green-button-of-Clone-or-download
$ cd gpiozero-recipes
$ python3 01-LED-blinky.py
Change the pin factory from its default RPi.GPIO to pigpio in order to get more precise measurement with supersonic distance sensor.
$ GPIOZERO_PIN_FACTORY=pigpio python3 07-distance-sensor-01.py