Skip to content

Instantly share code, notes, and snippets.

@gigafide
Created November 10, 2018 03:53
Show Gist options
  • Save gigafide/de62d481a3a306e4819a93311d6c9bf9 to your computer and use it in GitHub Desktop.
Save gigafide/de62d481a3a306e4819a93311d6c9bf9 to your computer and use it in GitHub Desktop.
Play music with a PIR motion detector and a Raspberry PI
#!/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