You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/tutorials/basic-movement.md
+30-18Lines changed: 30 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,23 +16,26 @@ The actual direction of travel of a motor, when mounted on a robot, will depend
16
16
Here's the code:
17
17
18
18
```python
19
-
from robot import Robot
20
-
import time
19
+
from sbot import Robot
21
20
22
21
r = Robot()
23
22
24
23
whileTrue:
25
24
r.motor_boards[0].m0.power =0.5
26
-
time.sleep(3)
25
+
r.motor_boards[0].m1.power =0.5
26
+
r.sleep(3)
27
27
28
28
r.motor_boards[0].m0.power =0
29
-
time.sleep(1.4)
29
+
r.motor_boards[0].m1.power =0
30
+
r.sleep(1.4)
30
31
31
32
r.motor_boards[0].m0.power =-0.5
32
-
time.sleep(1)
33
+
r.motor_boards[0].m1.power =-0.5
34
+
r.sleep(1)
33
35
34
36
r.motor_boards[0].m0.power =0
35
-
time.sleep(4)
37
+
r.motor_boards[0].m1.power =0
38
+
r.sleep(4)
36
39
```
37
40
38
41
You're familiar with the first few lines; in fact, the only lines you may not be familiar with are the `r.motor_boards...` lines. For a comprehensive reference to the `motor` object, see [`motor` API](/api/motor-board) page.
@@ -52,53 +55,62 @@ If you find that the motor doesn't turn when you run the above code, check that
52
55
Now we're going to modify the program to vary the speed of the motor. Our aim is to do the forwards and backwards bit (as above), but, before we loop round again, ramp the power up to 70%, then down to -70%, and then back to 0 (all in steps of 10%). Here's the code:
0 commit comments