mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Docs updates: add installing, advanced recipes, remote gpio and remote recipes - wip
This commit is contained in:
10
docs/examples/led_button_remote_1.py
Normal file
10
docs/examples/led_button_remote_1.py
Normal 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()
|
||||
12
docs/examples/led_button_remote_2.py
Normal file
12
docs/examples/led_button_remote_2.py
Normal 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()
|
||||
11
docs/examples/led_remote_1.py
Normal file
11
docs/examples/led_remote_1.py
Normal 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)
|
||||
14
docs/examples/led_remote_2.py
Normal file
14
docs/examples/led_remote_2.py
Normal 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)
|
||||
14
docs/examples/led_remote_3.py
Normal file
14
docs/examples/led_remote_3.py
Normal 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)
|
||||
14
docs/examples/led_remote_4.py
Normal file
14
docs/examples/led_remote_4.py
Normal 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)
|
||||
17
docs/examples/led_remote_5.py
Normal file
17
docs/examples/led_remote_5.py
Normal 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)
|
||||
14
docs/examples/multi_room_doorbell.py
Normal file
14
docs/examples/multi_room_doorbell.py
Normal 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()
|
||||
14
docs/examples/multi_room_motion_alert.py
Normal file
14
docs/examples/multi_room_motion_alert.py
Normal 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()
|
||||
7
docs/examples/traffichat_remote_1.py
Normal file
7
docs/examples/traffichat_remote_1.py
Normal 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
|
||||
8
docs/examples/traffichat_remote_2.py
Normal file
8
docs/examples/traffichat_remote_2.py
Normal 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
|
||||
Reference in New Issue
Block a user