Advertisement
Guest User

testPIRSensor

a guest
Apr 6th, 2020
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. import time
  3. import pygame
  4.  
  5. pygame.init()
  6. pygame.mixer.music.load("/home/pi/Desktop/bird.mp3")
  7. pygame.mixer.music.set_volume(10.0)
  8.  
  9. GPIO.setmode(GPIO.BCM)
  10.  
  11. GPIO.setup(23, GPIO.IN)
  12.  
  13. try:
  14.     time.sleep(5)
  15.     while True:
  16.         if GPIO.input(23):
  17.             print("motion")
  18.             pygame.mixer.music.play(3)
  19.             time.sleep(60)
  20.         time.sleep(1)
  21.         print("waiting")
  22. except:
  23.     GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement