Docs updates: add installing, advanced recipes, remote gpio and remote recipes - wip

This commit is contained in:
Ben Nuttall
2017-01-10 09:43:53 +00:00
parent ed12ac1994
commit dea7ba6ec2
19 changed files with 578 additions and 99 deletions

View File

@@ -0,0 +1,10 @@
from gpiozero import LED
from gpiozero.pins.pigpio import PiGPIOPin
from signal import pause
button = Button(2)
led = LED(PiGPIOPin(17, host='192.168.1.3'))
led.source = button.values
pause()

View File

@@ -0,0 +1,12 @@
from gpiozero import LED
from gpiozero.pins.pigpio import PiGPIOPin
from gpiozero.tools import all_values
from signal import pause
led = LED(17)
button_1 = Button(PiGPIOPin(17, host='192.168.1.3'))
button_2 = Button(PiGPIOPin(17, host='192.168.1.4'))
led.source = all_values(button_1.values, button_2.values)
pause()

View File

@@ -0,0 +1,11 @@
from gpiozero import LED
from gpiozero.pins.pigpio import PiGPIOPin
from time import sleep
led = LED(PiGPIOPin(17, host='192.168.1.3'))
while True:
led.on()
sleep(1)
led.off()
sleep(1)

View File

@@ -0,0 +1,14 @@
from gpiozero import LED
from gpiozero.pins.pigpio import PiGPIOPin
from time import sleep
led_1 = LED(PiGPIOPin(17, host='192.168.1.3'))
led_2 = LED(PiGPIOPin(17, host='192.168.1.4'))
while True:
led_1.on()
led_2.off()
sleep(1)
led_1.off()
led_2.on()
sleep(1)

View File

@@ -0,0 +1,14 @@
from gpiozero import LED
from gpiozero.pins.pigpio import PiGPIOPin
from time import sleep
led_1 = LED(17) # local pin
led_2 = LED(PiGPIOPin(17, host='192.168.1.3')) # remote pin
while True:
led_1.on()
led_2.off()
sleep(1)
led_1.off()
led_2.on()
sleep(1)

View File

@@ -0,0 +1,14 @@
from gpiozero import LED
from gpiozero.pins.rpigpio import RPiGPIOPin
from time import sleep
led_1 = LED(RPiGPIOPin(17)) # local pin
led_2 = LED(17) # remote pin
while True:
led_1.on()
led_2.off()
sleep(1)
led_1.off()
led_2.on()
sleep(1)

View File

@@ -0,0 +1,17 @@
from gpiozero import LED
from gpiozero.pins.pigpio import PiGPIOPin
from time import sleep
led_1 = LED(17) # local pin
led_2 = LED(PiGPIOPin(17, host='192.168.1.3')) # remote pin on one pi
led_3 = LED(PiGPIOPin(17, host='192.168.1.4')) # remote pin on another pi
while True:
led_1.on()
led_2.off()
led_3.on()
sleep(1)
led_1.off()
led_2.on()
led_3.off()
sleep(1)

View File

@@ -0,0 +1,14 @@
from gpiozero import Buzzer, Button
from gpiozero.pins.pigpio import PiGPIOPin
from signal import pause
ips = ['192.168.1.3', '192.168.1.4', '192.168.1.5', '192.168.1.6']
remote_pins = [PiGPIOPin(17, host=ip) for ip in ips]
button = Button(17) # button on this pi
buzzers = [Buzzer(pin) for pin in remote_pins] # buzzers on remote pins
for buzzer in buzzers:
buzzer.source = button.values
pause()

View File

@@ -0,0 +1,14 @@
from gpiozero import LEDBoard, MotionSensor
from gpiozero.pins.pigpio import PiGPIOPin
from signal import pause
ips = ['192.168.1.3', '192.168.1.4', '192.168.1.5', '192.168.1.6']
remote_pins = [PiGPIOPin(17, host=ip) for ip in ips]
leds = LEDBoard(2, 3, 4, 5) # leds on this pi
sensors = [MotionSensor(pin) for pin in remote_pins] # motion sensors on other pis
for led, sensor in zip(leds, sensors):
led.source = sensor.values
pause()

View File

@@ -0,0 +1,7 @@
import gpiozero
from gpiozero import TrafficHat
from gpiozero.pins.pigpio import PiGPIOFactory
from time import sleep
gpiozero.Device._set_pin_factory(PiGPIOFactory(host='192.168.1.3'))
th = TrafficHat() # traffic hat on 192.168.1.3 using remote pins

View File

@@ -0,0 +1,8 @@
import gpiozero
from gpiozero import TrafficHat
from gpiozero.pins.pigpio import PiGPIOFactory
from time import sleep
th_1 = TrafficHat() # traffic hat using local pins
gpiozero.Device._set_pin_factory(PiGPIOFactory(host='192.168.1.3'))
th_2 = TrafficHat() # traffic hat on 192.168.1.3 using remote pins