Created
November 10, 2018 03:53
-
-
Save gigafide/de62d481a3a306e4819a93311d6c9bf9 to your computer and use it in GitHub Desktop.
Play music with a PIR motion detector and a Raspberry PI
This file contains 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
#!/usr/bin/env python | |
import RPi.GPIO as GPIO | |
import pygame | |
import time | |
GPIO.setmode(GPIO.BOARD) | |
GPIO.setup(11, GPIO.IN) | |
pygame.mixer.init() | |
pygame.mixer.music.load("halloween.wav") | |
while True: | |
if GPIO.input(11): | |
print('motion') | |
pygame.mixer.music.get_busy() == True: | |
continue | |
time.sleep(5) | |
time.sleep(0.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment