forked from Tcm0/PybricksRemoteLayouts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
42099.py
42 lines (36 loc) · 1.14 KB
/
42099.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
from pybricks.pupdevices import *
from pybricks.parameters import *
from pybricks.tools import wait
steering = Motor(Port.C)
driving = Motor(Port.B)
driving2 = Motor(Port.A)
remoteControl = Remote()
#steering calibration sequence
steering.run_until_stalled(500)
steering.reset_angle(0)
steering.run_until_stalled(-500)
maxAngle = steering.angle()
steering.run_target(500, (maxAngle/2)+10)
steering.reset_angle(0)
#main loop
while True:
#update pressed buttons information
pressed = remoteControl.buttons.pressed()
#commands to drive forwards or backwards
if Button.LEFT_PLUS in pressed:
driving.dc(100)
driving2.dc(100)
elif Button.LEFT_MINUS in pressed:
driving.dc(-100)
driving2.dc(-100)
else:
driving.brake()
driving2.brake()
#commands to steer
if Button.RIGHT_PLUS in pressed:
steering.run_target(1200, (maxAngle/2)-5, Stop.HOLD,False)
elif Button.RIGHT_MINUS in pressed:
steering.run_target(1200, -((maxAngle/2)-5), Stop.HOLD,False)
else:
steering.run_target(1200, 0, Stop.HOLD, False)
wait(100)