Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
clean up
  • Loading branch information
Mubaraq Olayinka committed Jul 30, 2024
1 parent 5522a8b commit 5c1a8ef
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sensor.py
Expand Up @@ -21,7 +21,7 @@
def on_motion_detected(channel):
print("Motion Detected!")
client.publish(MQTT_TOPIC, "Motion Detected")

# Add event detection on the PIR pin
GPIO.add_event_detect(PIR_PIN, GPIO.RISING, callback=on_motion_detected)

Expand All @@ -30,4 +30,10 @@ def on_motion_detected(channel):
time.sleep(2) # to stabilize sensor
print("Ready")

# Keep the script running
while True:
time.sleep(1)

except KeyboardInterrupt:
print("Quit")
GPIO.cleanup()

0 comments on commit 5c1a8ef

Please sign in to comment.