Package lejos.hardware.motor
Class BasicMotor
- java.lang.Object
-
- lejos.hardware.Device
-
- lejos.hardware.motor.BasicMotor
-
-
Field Summary
Fields Modifier and Type Field Description protected static intINVALID_MODEprotected intmodeprotected BasicMotorPortportprotected intpower
-
Constructor Summary
Constructors Constructor Description BasicMotor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbackward()Causes motor to rotate backwards.voidflt()Causes motor to float.voidforward()Causes motor to rotate forward.intgetPower()Returns the current motor power setting.booleanisMoving()Returns true iff the motor is in motion.voidsetPower(int power)Set the power level 0%-100% to be applied to the motorvoidstop()Causes motor to stop, pretty much instantaneously.protected voidupdateState(int newMode)Update the internal state tracking the motor direction-
Methods inherited from class lejos.hardware.Device
close, releaseOnClose
-
-
-
-
Field Detail
-
INVALID_MODE
protected static int INVALID_MODE
-
mode
protected int mode
-
port
protected BasicMotorPort port
-
power
protected int power
-
-
Method Detail
-
setPower
public void setPower(int power)
Description copied from interface:DCMotorSet the power level 0%-100% to be applied to the motor
-
getPower
public int getPower()
Description copied from interface:DCMotorReturns the current motor power setting.
-
updateState
protected void updateState(int newMode)
Update the internal state tracking the motor direction- Parameters:
newMode-
-
forward
public void forward()
Causes motor to rotate forward.
-
backward
public void backward()
Causes motor to rotate backwards.
-
isMoving
public boolean isMoving()
Returns true iff the motor is in motion.
-
flt
public void flt()
Causes motor to float. The motor will lose all power, but this is not the same as stopping. Use this method if you don't want your robot to trip in abrupt turns.
-
-