by sam9s » 09 May 2018, 12:46
Hi All
I am, also trying to get the play pause executed to runeaudio via GPIO. When I execute the script get the error ..
#python2 hw_pause_play.py
File "hw_pause_play.py", line 21
mpc toggle
^
SyntaxError: invalid syntax
If I type mpc toggle on the command line it works but ith script it does not. Below is the script I created
Below is the script I am using ...... CAN anyone assist PLEASE!!!1
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import subprocess
GPIO.setmode(GPIO.BOARD)
# When pressed, execute this command:
print "*** Button press detected ***" # (print statement added only for debugging)
subprocess.call("mpc toggle", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PI$
# Select unused GPIO header pin to be used to toggle play/pause
InputPin = 13
# Set selected pin to input, and enable internal pull-up
GPIO.setup(InputPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# Wait for a button press on the selected pin (pulled to ground, falling edge)
GPIO.wait_for_edge(InputPin, GPIO.FALLING)
# When pressed, toggle play/pause
mpc toggle