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
integer
None
1
2
3
use Libraries.Robots.Spike.Motor
Motor wheel
integer wheelPort = wheel:GetPort()
None
integerport
The 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)
integer
None
1
2
3
use Libraries.Robots.Spike.Motor
Motor wheel
integer currentPWM = wheel:GetDutyCyle()
None
integerpulseWidthModulation
The 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)
integer
None
1
2
3
use Libraries.Robots.Spike.Motor
Motor wheel
integer currentRelativeWheelPosition = wheel:GetRelativePosition()
None
integerposition
The 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)
integer
None
1
2
3
use Libraries.Robots.Spike.Motor
Motor wheel
integer currentAbsoluteWheelPosition = wheel:GetAbsolutePosition()
None
integervelocity
The 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)
None
integertime
The time, in miliseconds, that the motor will run for with the given velocity.
integervelocity
The 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)
None
integerdegrees
The degrees that the motor will run for with the given velocity.
integervelocity
The 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)
None
integerposition
The position that the motor will use to turn to relative to the current position.
integervelocity
The 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)
None
integerposition
The absolute position that the motor will use to turn to.
integervelocity
The 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)
None
None
1
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()
integer
None
1
2
3
4
use Libraries.Robots.Spike.Motor
Motor wheel
wheel:Run(360)
integer currentVelocity = wheel:GetVelocity()