forked from arraypan/MakerFaire-NerfTurret
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaker.py
More file actions
executable file
·30 lines (22 loc) · 757 Bytes
/
Copy pathmaker.py
File metadata and controls
executable file
·30 lines (22 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import RPi.GPIO as GPIO
from evdev import InputDevice, categorize, ecodes, KeyEvent
from select import select
import time
gamepad = InputDevice('/dev/input/event2')
servoPIN = 20
GPIO.setmode(GPIO.BCM)
GPIO.setup(servoPIN, GPIO.OUT)
GPIO.setwarnings(False)
for event in gamepad.read_loop():
if event.type == ecodes.EV_KEY:
keyevent = categorize(event)
if keyevent.keystate == KeyEvent.key_down:
print(keyevent.keycode[0])
if keyevent.keycode[0] == 'B':
GPIO.output(servoPIN, GPIO.LOW)
print("set GIOP high")
# time.sleep(2)
else:
GPIO.output(servoPIN, GPIO.HIGH)
else:
GPIO.output(servoPIN, GPIO.HIGH)