Skip to content

Instantly share code, notes, and snippets.

@bunchc
Last active February 11, 2019 21:31
Show Gist options
  • Save bunchc/cb9d6289d4bd15ab72d2a80afc3004bc to your computer and use it in GitHub Desktop.
Save bunchc/cb9d6289d4bd15ab72d2a80afc3004bc to your computer and use it in GitHub Desktop.
There Are Door Lights - Light Sensor
from gpiozero import LightSensor
import hub_ctrl
sensor = LightSensor(4)
print(sensor.light_detected)
while True:
# sensor.when_light = hub_ctrl.send_command(listing=True, busnum=1, devnum=2, hub=None, port=2, value=1, verbose=False)
sensor.wait_for_light()
hub_ctrl.send_command(listing=True, busnum=1, devnum=2, hub=None, port=2, value=1, verbose=False)
#sensor.when_dark = hub_ctrl.send_command(listing=True, busnum=1, devnum=2, hub=None, port=2, value=0, verbose=False)
sensor.wait_for_dark()
hub_ctrl.send_command(listing=True, busnum=1, devnum=2, hub=None, port=2, value=0, verbose=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment