-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkojr.py
executable file
·56 lines (47 loc) · 1.17 KB
/
kojr.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import RPi.GPIO as io
import time
# Currently able to reach about 500-700 jumps
time.sleep(1)
# setup GPIO
io.setmode(io.BCM)
solenoid = 25
io.setup(solenoid, io.OUT)
# start the game
io.output(solenoid, 1)
time.sleep(0.05)
io.output(solenoid, 0)
time.sleep(1)
# initial jump interval of .60 seconds
timing = 0.60
# Tricky variable is for every other jump in the "double tap" jumps of 200-300
tricky = False
try:
for jump in range(1, 1000):
print jump
# push the solenoid
io.output(solenoid, 1)
time.sleep(0.05)
# pull the solenoid
io.output(solenoid, 0)
# adjust the timing for the current jump
if jump == 20:
timing = 0.489
elif jump == 49:
timing = 0.415
elif jump == 99:
timing = 0.382
elif jump == 199:
timing = 0.298
tricky = True
elif jump == 299:
timing = 0.350
time.sleep(timing)
# For the tricky "double tap" tricky jumps between 200-300
if jump in range(201, 298):
if tricky == True:
time.sleep(0.07)
tricky = False
else:
tricky = True
except:
io.cleanup()