Advertisement
chg1730

MotionClock

Jan 25th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. import time
  3. import vlc
  4. import os
  5. GPIO.setmode(GPIO.BOARD)
  6. GPIO.setwarnings(False)
  7. GPIO.setup(7, GPIO.IN)
  8. p = vlc.MediaPlayer("/home/pi/Documents/ALARM2.mp3")
  9. on = False
  10. printed = False
  11. motion = False
  12. volume = 50 #STARTING VOLUME
  13. try:
  14.     while motion == False:
  15.         print(volume)
  16.         os.system("sudo amixer set PCM -- "+str(volume)+"%")
  17.         p.play()
  18.         time.sleep(3)
  19.         p.stop()
  20.         volume += 4
  21.         if(volume > 100):
  22.             volume = 100
  23.         motion = GPIO.input(7)
  24. except KeyboardInterrupt:
  25. GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement