forked from BringusStudios/pipico-operation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinc_on_space.py
More file actions
42 lines (33 loc) · 1.09 KB
/
Copy pathinc_on_space.py
File metadata and controls
42 lines (33 loc) · 1.09 KB
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
#
# This is the code for the 1st gamemode featured at the end of the video.
import time
import keyboard
from picocom import PiPicoCommunicator
initial_level = 10
increment = 7.5
power_level = initial_level
pico = PiPicoCommunicator(port='COM11', debug=False)
print("Pico connected\nIncreasing power level by " + str(increment) + "% upon spacebar press and starting at " + str(initial_level) + "% power\n\n\n")
pico.rumble("all", 0)
def feedback():
i = 3
while i > 0:
pico.rumble("all", 20)
time.sleep(0.05)
pico.rumble("all", 0)
time.sleep(0.05)
i -= 1
while True:
if keyboard.is_pressed('space'):
if power_level == 100:
power_level = 10
print("Power level reset to", power_level, "%")
else:
power_level += increment
print("Power level increased to", power_level, "%")
feedback()
button = pico.check_state()
if button == 'contact':
pico.rumble("all", power_level)
elif button == 'no_contact':
pico.rumble("all", 0)