Skip to content

Instantly share code, notes, and snippets.

@Unitoi01
Last active March 12, 2018 15:26
Show Gist options
  • Save Unitoi01/700fbf4e8f4961ae7240167f41be1432 to your computer and use it in GitHub Desktop.
Save Unitoi01/700fbf4e8f4961ae7240167f41be1432 to your computer and use it in GitHub Desktop.
Button for walkie talkie
import RPi.GPIO as GPIO
import time
import sys
GPIO.setmode(GPIO.BCM)
GPIO.setup(14, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state = GPIO.input(14)
if input_state == False:
print('Button Pressed')
sys.stdout.write("amixer cset numid=3 2")
sys.stdout.write("sudo ./hub-ctrl -h 0 -P 2 -p 1")
time.sleep(0.2)
else if input_state==True:
sys.stdout.write("amixer cset numid=3 1")
sys.stdout.write("sudo ./hub-ctrl -h 0 -P 2 -p 0")
time.sleep(0.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment