Advertisement
AceScottie

headlights

Aug 2nd, 2018
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. from evdev import InputDevice, categorize, ecodes
  2. gamepad = InputDevice('/dev/input/event0')
  3. print(gamepad)
  4. state = 0
  5. while True:
  6.     try:
  7.         for event in gamepad.read_loop():
  8.             if event.type == ecodes.EV_KEY and event.value == 1 and event.code == 304:
  9.                 if state == 0:
  10.                     state = 1
  11.                     a.digitalWrite(12, a.HIGH)
  12.                 elif state == 1:
  13.                     state = 0
  14.                     a.digitalWrite(12, a.LOW)
  15.     except KeyboardInterrupt:
  16.         break
  17.     except:
  18.         raise
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement