Advertisement
Guest User

Mute

a guest
Feb 21st, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. #!/usr/bin/python
  2. import RPi.GPIO as GPIO
  3. import time
  4. import subprocess
  5. import alsaaudio
  6.  
  7. # we will use the pin numbering to match the pins on the Pi, instead of the
  8. # GPIO pin outs (makes it easier to keep track of things)
  9.  
  10. GPIO.setmode(GPIO.BOARD)
  11.  
  12.  
  13. # use the same pin that is used for the reset button (one button to rule them all!)
  14. GPIO.setup(12, GPIO.IN, pull_up_down = GPIO.PUD_UP)
  15.  
  16. m = alsaaudio.Mixer('PCM')
  17. m.setvolume(100)
  18.  
  19. while True:
  20.     #grab the current button state
  21.     buttonState1 = GPIO.input(12)
  22.  
  23.     # check to see if button has been pushed
  24.     if buttonState1 != False:
  25.         if m.getmute()[0] == 0:
  26.           m.setmute(0)
  27.         else:
  28.           m.setmute(1)      
  29.  
  30.     time.sleep(.1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement