stronk_8s

PIR Sensor

Nov 24th, 2025 (edited)
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | Source Code | 0 0
  1. import RPi.GPIO as GPIO
  2. import time
  3. GPIO.setmode(GPIO.BCM)
  4. GPIO.setup(24,GPIO.OUT)
  5. GPIO.setup(18,GPIO.IN)
  6.  
  7. while(True):
  8.     myin=GPIO.input(18)
  9.     if myin==True:
  10.         print("Motion Detectedc")
  11.         GPIO.output(24,True)
  12.         time.sleep(0.5)
  13.         GPIO.output(24,False)
  14.         time.sleep(0.5)
  15.     else:
  16.         print("Motion not detectedc")
  17.         time.sleep(1)
  18.  
Advertisement
Add Comment
Please, Sign In to add comment