Exemplo n.º 1
0
#!/usr/bin/env python

print("Loading gpiozero")

from gpiozero import LEDBoard, ButtonBoard
from signal import pause

leds = LEDBoard(4, 18, 6, 13)
btns = ButtonBoard(17, 25, 24, 16)

print("Press A button, closest LED will light...")
print("Ctrl-C to exit\n")

while True :
  try:
    leds.source = btns
    pause()
  except KeyboardInterrupt:
    print("\rExiting..")
    exit(0)


from gpiozero import LEDBoard, MotionSensor
from gpiozero.pins.pigpio import PiGPIOFactory
from gpiozero.tools import zip_values
from signal import pause

ips = ['192.168.1.3', '192.168.1.4', '192.168.1.5', '192.168.1.6']
remotes = [PiGPIOFactory(host=ip) for ip in ips]

leds = LEDBoard(2, 3, 4, 5)  # leds on this pi
sensors = [MotionSensor(17, pin_factory=r) for r in remotes]  # remote sensors

leds.source = zip_values(*sensors)

pause()