@@ -127,7 +127,7 @@ while True:
127
127
~~~~~
128
128
129
129
You're familiar with the first few lines; in fact, the only lines you may not be familiar with are the ` R.motor_board... ` lines.
130
- For a comprehensive reference to the ` motor ` object, see the ` sr.robot3 ` module's [ ` motor ` ] ( /docs/programming/sr/motors/ ) page.
130
+ For a comprehensive reference to the ` motor ` object, see the ` sr.robot3 ` module's [ Motors ] ( /docs/programming/sr/motors/ ) page.
131
131
But, to summarise:
132
132
133
133
<div class =" info " markdown =" 1 " >
@@ -139,6 +139,7 @@ But, to summarise:
139
139
140
140
So, ` R.motor_board.motors[0].power = 0.5 ` sets the target power of the motor connected to output 0 on the first [ motor board] ( /docs/kit/motor_board )
141
141
plugged in to a USB hub to 50% forwards (i.e. a duty-cycle of 0.5 forwards).
142
+
142
143
As you would expect, then, ` R.motor_board.motors[0].power = -0.5 ` will put the this motor into reverse at 50% power.
143
144
` R.motor_board.motors[0].power = 0 ` will output no power to the motor and stop it.
144
145
@@ -213,6 +214,7 @@ while True:
213
214
214
215
Again, as you've seen most of that before, it shouldn't be too difficult to get your head around.
215
216
The ` for ` loop may be new, however.
217
+
216
218
The [ ` for ` ] ( https://docs.python.org/tutorial/controlflow.html#for-statements )
217
219
loop accepts a Python ` list ` (a ` list ` , when ` print ` ed, appears in square brackets like so: ` [1, 2, 3] ` ).
218
220
For a comprehensive introduction to to ` list ` s, have a look at [ this WikiBooks article] ( https://en.wikibooks.org/wiki/Python_Programming/Lists ) .
@@ -222,7 +224,7 @@ Here's an example:
222
224
223
225
~~~~~ python
224
226
for i in [1 , 2 , 3 ]:
225
- print (i)
227
+ print (i)
226
228
~~~~~
227
229
228
230
The above would output:
0 commit comments