Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from evdev import InputDevice, categorize, ecodes
- gamepad = InputDevice('/dev/input/event0')
- print(gamepad)
- state = 0
- while True:
- try:
- for event in gamepad.read_loop():
- if event.type == ecodes.EV_KEY and event.value == 1 and event.code == 304:
- if state == 0:
- state = 1
- a.digitalWrite(12, a.HIGH)
- elif state == 1:
- state = 0
- a.digitalWrite(12, a.LOW)
- except KeyboardInterrupt:
- break
- except:
- raise
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement