Thank you for your donation!


Python Code with Moode
#5
(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.

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)
Thanks Sharkus,
Great! That looks like that will get me started in the right direction.

Thanks again,
Gary
Reply


Messages In This Thread
Python Code with Moode - by Big G - 04-10-2018, 10:42 PM
RE: Python Code with Moode - by rikardo1979 - 04-10-2018, 11:16 PM
RE: Python Code with Moode - by Big G - 04-16-2018, 03:00 PM
RE: Python Code with Moode - by Sharkus - 04-16-2018, 03:32 PM
RE: Python Code with Moode - by Big G - 04-16-2018, 03:44 PM

Forum Jump: