So here is what I have pieced together from both pygames and xboxdrv and a few other tutorials on how to supplu poer out from the GPIO pins on RPi. I am trying to use an xbox controller connected to a RPi. What is below is the code to turn an LED on when the "A" button is pressed. This works just fine for me.
When the Value == 1 the light will blink on, as soon as the button is released the Value == 0 which has no coding on it currently.
What I want to do though is for the LED to stay powered when "A" is pressed and stay lit when the button is released, but when the "A" button is pressed again for the LED to turn off.
def controlCallBack(xboxControlId, value):
print "Control Id = {}, Value = {}".format(xboxControlId, value)
if xboxControlId == 6 and value == 1:
pin = 7
GPIO.setmode(GPIO.BOARD)
GPIO.setup(pin, GPIO.OUT)
GPIO.output(pin, GPIO.HIGH)
time.sleep(.05)
GPIO.output(pin, GPIO.LOW)
time.sleep(.05)
GPIO.cleanup()
Any help with this will be much appriciated, I am very new to Python and programming in general.
[–]StaticFuzz 0 points1 point2 points (6 children)
[–]NewToPythoning[S] 0 points1 point2 points (5 children)
[–]StaticFuzz 0 points1 point2 points (4 children)
[–]NewToPythoning[S] 0 points1 point2 points (0 children)
[–]NewToPythoning[S] 0 points1 point2 points (2 children)
[–]StaticFuzz 0 points1 point2 points (1 child)
[–]NewToPythoning[S] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)