Motors
Motors can be used for all sorts of things, besides just moving your robot. For instance, they could also be used as part of a mechanism to collect cubes. However you decide to use them, they’re really simple to control.
When you control motors, you can choose how much power you want to give them. This is expressed as a percentage, so 0% means a stopped motor and 100% means a motor at full power.
If you want to spin your motors in reverse, just stick a negative sign in front of your percentage. Values outside of -100 to 100 are limited to that range, so setting a motor to 150 is the same as setting it to 100.
Python
You can control motors using the motors property of the IO object. To set the power of the first motor to 60% use:
I.motors[0] = 60Remember that indexes start at 0; To control the second motor instead, replace motors[0] with motors[1].
To stop both motors:
I.motors[0] = 0I.motors[1] = 0When your robot has completely finished, I.stop() stops both motors and also turns off the 12v power. It doesn’t move your servos. If you only want to pause, set the motors to 0 as above instead.
Here’s a more complete example:
from robocon.brain import IO
I = IO()
# set motor 0 to 60% powerI.motors[0] = 60
# set motor 1 to 60% power in the backwards directionI.motors[1] = -60
# turn both motors offI.motors[0] = 0I.motors[1] = 0Blockly
Blocks for controlling motors can be found in the Movement section. It follows a similar structure to how the python is layed out, with motors being set to a value between -100 and 100 to control their rotation speed.