Created
          October 3, 2019 05:27 
        
      - 
      
- 
        Save cyrus007/93f493c855baf3f92f2c0fbf413d7234 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import RPi.GPIO as GPIO | |
| import time | |
| GPIO.setmode(GPIO.BCM) | |
| GPIO.setup(23, GPIO.IN) #PIR | |
| GPIO.setup(24, GPIO.OUT) #BUzzer | |
| try: | |
| time.sleep(2) # to stabilize sensor | |
| while True: | |
| if GPIO.input(23): | |
| GPIO.output(24, True) | |
| time.sleep(0.5) #Buzzer turns on for 0.5 sec | |
| GPIO.output(24, False) | |
| print("Motion Detected...") | |
| time.sleep(5) #to avoid multiple detection | |
| time.sleep(0.1) #loop delay, should be less than detection delay | |
| except: | |
| GPIO.cleanup() | 
      
      
  Author
  
  
        
      
            cyrus007
  
      
      
      commented 
        Oct 3, 2019 
      
    
  
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment