Skip to content

Instantly share code, notes, and snippets.

@everblut
Created May 24, 2012 16:09
Show Gist options
  • Save everblut/2782461 to your computer and use it in GitHub Desktop.
Save everblut/2782461 to your computer and use it in GitHub Desktop.
Python controlador musica
import serial
import os
def U():
print 'boton Up volumen++'
os.system("amixer sset Master playback 5%+")
def D():
print 'boton Down volmen--'
os.system("amixer sset Master playback 5%-")
def L():
print 'boton L restart'
os.system("banshee --restart-or-previous")
def R():
print 'boton R next song'
os.system("banshee --next")
def A():
print 'boton A toogle playing'
os.system("banshee --toggle-playing")
def S():
print 'boton Start inicia banshee'
os.system("banshee &")
def C():
print 'Boton select termina banshee'
os.system("killall banshee")
def B():
print 'boton B stop'
os.system("banshee --stop")
def N():
print 'Nada'
def run(program, *args):
pid = os.fork()
if not pid:
os.execvp(program, (program,) + args)
return os.wait()[0]
s = serial.Serial("/dev/ttyACM"+raw_input("En que puerto serial esta el arduino: "),9600)
while(1):
case = {
'U' : U,
'D' : D,
'R' : R,
'L' : L,
'S' : S,
'A' : A,
'B' : B,
'N' : N,
'C' : C,
}
case[s.read()]()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment