From ac70e9e89b44fa648c43e837e5331d4ab540bf28 Mon Sep 17 00:00:00 2001 From: Raspy 94 <31358813+Raspy94@users.noreply.github.com> Date: Sat, 3 Oct 2020 16:06:46 +0100 Subject: [PATCH] Create PIR motion --- PIR motion | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 PIR motion diff --git a/PIR motion b/PIR motion new file mode 100644 index 0000000..8975dc0 --- /dev/null +++ b/PIR motion @@ -0,0 +1,16 @@ +import RPi.GPIO as GPIO +import time +GPIO.setmode(GPIO.BCM) +PIR_PIN = 4 +GPIO.setup(PIR_PIN, GPIO.IN) +try: + print ('PIR Module Test CTRL+C to exit') + time.sleep(2) + print ('Ready') + while True: + if GPIO.input(PIR_PIN): + print ('Motion') + time.sleep(1) +except KeyboardInterrupt: + print (' Quit') + GPIO.cleanup()