public class Motor extends Part
Modifier and Type | Field and Description |
---|---|
static int |
LEFT
Motor id for left motor.
|
static int |
RIGHT
Motor id for right motor.
|
Constructor and Description |
---|
Motor(int id)
Creates a motor instance with given id.
|
Modifier and Type | Method and Description |
---|---|
void |
backward()
Starts the backward rotation.
|
void |
forward()
Starts the forward rotation.
|
int |
getId()
Returns the port of the motor.
|
int |
getSpeed()
Returns the current speed (arbitrary units).
|
boolean |
isMoving()
Checks if motor is rotating.
|
void |
setSpeed(int speed)
Sets the speed to the given value (arbitrary units).
|
void |
stop()
Stops the rotation.
|
public static int LEFT
public static int RIGHT
public Motor(int id)
id
- 0 for left motor, 1 for right motorpublic void forward()
public void backward()
public void stop()
public void setSpeed(int speed)
speed
- the speed 0..100public int getSpeed()
public int getId()
public boolean isMoving()