Skip to content

Commit bbfb23e

Browse files
committed
update to new api name
1 parent 8efac12 commit bbfb23e

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

content/tutorials/basic-movement.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,22 @@ The actual direction of travel of a motor, when mounted on a robot, will depend
1616
Here's the code:
1717

1818
```python
19-
from robot import Robot
20-
import time
19+
from sbot import Robot
2120

2221
r = Robot()
2322

2423
while True:
2524
r.motor_boards[0].m0.power = 0.5
26-
time.sleep(3)
25+
r.sleep(3)
2726

2827
r.motor_boards[0].m0.power = 0
29-
time.sleep(1.4)
28+
r.sleep(1.4)
3029

3130
r.motor_boards[0].m0.power = -0.5
32-
time.sleep(1)
31+
r.sleep(1)
3332

3433
r.motor_boards[0].m0.power = 0
35-
time.sleep(4)
34+
r.sleep(4)
3635
```
3736

3837
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 +51,52 @@ If you find that the motor doesn't turn when you run the above code, check that
5251
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:
5352

5453
```python
55-
from robot import Robot
56-
import time
54+
from sbot import Robot
5755

5856
r = Robot()
5957

6058
while True:
6159
r.motor_boards[0].m0.power = 0.5
62-
time.sleep(3)
60+
r.sleep(3)
6361

6462
r.motor_boards[0].m0.power = 0
65-
time.sleep(1.4)
63+
r.sleep(1.4)
6664

6765
r.motor_boards[0].m0.power = -0.5
68-
time.sleep(1)
66+
r.sleep(1)
6967

7068
r.motor_boards[0].m0.power = 0
71-
time.sleep(4)
69+
r.sleep(4)
7270

7371
# ^^ code from before ^^
7472

7573
# power up to 0.7 (from 0.1)
7674
for pwr in range(10, 80, 10):
7775
r.motor_boards[0].m0.power = pwr / 100.0
78-
time.sleep(0.1)
76+
r.sleep(0.1)
7977

8078
# power down from 0.7 (to 0.1)
8179
for pwr in range(70, 0, -10):
8280
r.motor_boards[0].m0.power = pwr / 100.0
83-
time.sleep(0.1)
81+
r.sleep(0.1)
8482

8583
# set power to 0 for a second
8684
r.motor_boards[0].m0.power = 0
87-
time.sleep(1)
85+
r.sleep(1)
8886

8987
# power up to -0.7 (from -0.1)
9088
for pwr in range(-10, -80, -10):
9189
r.motor_boards[0].m0.power = pwr / 100.0
92-
time.sleep(0.1)
90+
r.sleep(0.1)
9391

9492
# power down to -0.1 (from -0.7)
9593
for pwr in range(-70, 0, 10):
9694
r.motor_boards[0].m0.power = pwr / 100.0
97-
time.sleep(0.1)
95+
r.sleep(0.1)
9896

9997
# set power to 0 for a second
10098
r.motor_boards[0].m0.power = 0
101-
time.sleep(1)
99+
r.sleep(1)
102100
```
103101

104102
## Next steps

0 commit comments

Comments
 (0)