04-16-2018, 03:44 PM
(04-16-2018, 03:32 PM)Sharkus Wrote: Here's a simple example of how you can use a button connected on GPIO(4) to pause/play a song. I use this as part of the script that drives a 128x128 OLED display.Thanks Sharkus,
Code:import subprocess
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def mpdToggle():
status = subprocess.check_output(['mpc', 'toggle'])
def main():
while True:
input_state = GPIO.input(4)
if input_state == False:
mpdToggle()
time.sleep(pauseTime)
Great! That looks like that will get me started in the right direction.
Thanks again,
Gary