Difference between revisions of "Tutorial:Motors"
From IPRE Wiki
(→Example) |
|||
Line 1: | Line 1: | ||
==How to use Myro Motors== | ==How to use Myro Motors== | ||
− | motors( | + | motors(LEFT,RIGHT) |
− | The motors | + | The motors function is used to move the robot forward or backward with variable power to the two wheels. LEFT and RIGHT correspond to the power to the left wheel's motor and the power to the right wheel's motor, respectively. |
− | The | + | The LEFT and RIGHT parameters are between -1.0 (for full speed backward) and 1.0 (full speed forward). |
motors does not take in a time parameter, so the robot will continue to run until it encounters a stop() or other incompatible command. | motors does not take in a time parameter, so the robot will continue to run until it encounters a stop() or other incompatible command. | ||
Line 23: | Line 23: | ||
<br><nowiki> </nowiki>backward(1,10) | <br><nowiki> </nowiki>backward(1,10) | ||
<br>goRobotGo() | <br>goRobotGo() | ||
+ | |||
+ | ===For more information...=== | ||
+ | |||
+ | <br>See http://wiki.roboteducation.org/Chapter_2#The_Scribbler_Robot:_Movements | ||
[[Category:Tutorials]] | [[Category:Tutorials]] |
Latest revision as of 19:56, 4 December 2007
How to use Myro Motors
motors(LEFT,RIGHT)
The motors function is used to move the robot forward or backward with variable power to the two wheels. LEFT and RIGHT correspond to the power to the left wheel's motor and the power to the right wheel's motor, respectively.
The LEFT and RIGHT parameters are between -1.0 (for full speed backward) and 1.0 (full speed forward).
motors does not take in a time parameter, so the robot will continue to run until it encounters a stop() or other incompatible command.
Example
This code will turn the robot in a circle to the left in place for 3 seconds, stop, turn in place to the right for 3 seconds, then go backward for 10 seconds and stop.
def goRobotGo():
from myro import *
initialize()
motors(-1,1)
wait(3)
stop()
motors(1,-1)
wait(3)
backward(1,10)
goRobotGo()
For more information...
See http://wiki.roboteducation.org/Chapter_2#The_Scribbler_Robot:_Movements