The motor is an external device that is connected to the hub through a port. It is a rotational device that can be attached to other objects to provide force. The motor library has various functions that can set the port of the motor, control the motor to run for some specified parameters, and get some data abour the motor. Ranges for velocity vary per motor size as follows: Small motor: -660 to 660, Medium motor: -1110 to 1110, Large motor: -1050 to 1050
integerNone1
2
3
use Libraries.Robots.Spike.Motor
Motor wheel
integer wheelPort = wheel:GetPort()NoneintegerportThe port (0 through 5) the motor is attached to and what port number the motor object will be set to
1
2
3
use Libraries.Robots.Spike.Motor
Motor wheel
wheel:SetPort(0)integerNone1
2
3
use Libraries.Robots.Spike.Motor
Motor wheel
integer currentPWM = wheel:GetDutyCyle()NoneintegerpulseWidthModulationThe pulse width modulation, from -10000 - 10000, that will be used to start this motor with
1
2
3
use Libraries.Robots.Spike.Motor
Motor wheel
wheel:SetDutyCycle(5000)integerNone1
2
3
use Libraries.Robots.Spike.Motor
Motor wheel
integer currentRelativeWheelPosition = wheel:GetRelativePosition()NoneintegerpositionThe relative position that will be used to change the position used as an offset for RunToRelativePosition()
1
2
3
use Libraries.Robots.Spike.Motor
Motor wheel
wheel:SetRelativePosition(90)integerNone1
2
3
use Libraries.Robots.Spike.Motor
Motor wheel
integer currentAbsoluteWheelPosition = wheel:GetAbsolutePosition()NoneintegervelocityThe velocity, in degrees per second, that the motor will be started with.
1
2
3
use Libraries.Robots.Spike.Motor
Motor wheel
wheel:Run(90)NoneintegertimeThe time, in miliseconds, that the motor will run for with the given velocity.
integervelocityThe velocity, in degrees per second, that the motor will be started with.
1
2
3
use Libraries.Robots.Spike.Motor
Motor wheel
wheel:RunForTime(2000, 360)NoneintegerdegreesThe degrees that the motor will run for with the given velocity.
integervelocityThe velocity, in degrees per second, that the motor will be started with.
1
2
3
use Libraries.Robots.Spike.Motor
Motor wheel
wheel:RunToDegrees(720, 90)NoneintegerpositionThe position that the motor will use to turn to relative to the current position.
integervelocityThe velocity, in degrees per second, that the motor will be started with.
1
2
3
use Libraries.Robots.Spike.Motor
Motor wheel
wheel:RunToRelativePosition(360, 360)NoneintegerpositionThe absolute position that the motor will use to turn to.
integervelocityThe velocity, in degrees per second, that the motor will be started with.
1
2
3
use Libraries.Robots.Spike.Motor
Motor wheel
wheel:RunToAbsolutePosition(1200, 360)NoneNone1
2
3
4
5
6
7
use Libraries.Robots.Spike.Motor
use Libraries.Robots.Spike.Hub
Motor wheel
Hub hb
wheel:Run(360)
hb:Sleep(1000)
wheel:Stop()integerNone1
2
3
4
use Libraries.Robots.Spike.Motor
Motor wheel
wheel:Run(360)
integer currentVelocity = wheel:GetVelocity()