mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Add more advanced and remote recipes
This commit is contained in:
18
docs/examples/whos_home_status.py
Normal file
18
docs/examples/whos_home_status.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from gpiozero import PingServer, StatusZero
|
||||
from gpiozero.tools import negated
|
||||
from signal import pause
|
||||
|
||||
status = StatusZero('mum', 'dad', 'alice')
|
||||
|
||||
statuses = {
|
||||
PingServer('192.168.1.5'): status.mum,
|
||||
PingServer('192.168.1.6'): status.dad,
|
||||
PingServer('192.168.1.7'): status.alice,
|
||||
}
|
||||
|
||||
for server, leds in statuses.items():
|
||||
leds.green.source = server.values
|
||||
leds.green.source_delay = 60
|
||||
leds.red.source = negated(leds.green.values)
|
||||
|
||||
pause()
|
||||
Reference in New Issue
Block a user