rcx.rcxdirect
Class Motor

java.lang.Object
  extended by rcx.rcxdirect.DirectSend
      extended by rcx.rcxdirect.Motor

public class Motor
extends DirectSend

Abstraction for a motor. Three instances of Motor are available: Motor.A, Motor.B and Motor.C. To control each motor use methods forward, backward, reverseDirection, stop and flt. To set each motor's power, use setPower.

Example:

   Motor.A.setPower(1);
   Motor.C.setPower(7);
   Motor.A.forward();
   Motor.C.forward();
   Thread.sleep (1000);
   Motor.A.stop();
   Motor.C.stop();
 


Field Summary
static Motor A
          Motor A.
static Motor B
          Motor B.
static Motor C
          Motor C.
 
Constructor Summary
Motor(int aId)
           
 
Method Summary
 void backward()
          Causes motor to rotate backwards.
 void controlMotor(int aMotor, int aState)
           
 void controlMotorPower(int aMotor, int aValue)
           
 void flt()
          Causes motor to float.
 void forward()
          Causes motor to rotate forward.
 int getPower()
          Returns the current motor power.
 void setPower(int aPower)
          Sets motor power to a value between 0 and 7.
 void stop()
          Causes motor to stop, pretty much instantaneously.
 
Methods inherited from class rcx.rcxdirect.DirectSend
getStream, getTimeout, getTimeoutStatic, init, lastResult, lastResultStatic, sendToRCX
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

A

public static final Motor A
Motor A.


B

public static final Motor B
Motor B.


C

public static final Motor C
Motor C.

Constructor Detail

Motor

public Motor(int aId)
Method Detail

setPower

public final void setPower(int aPower)
Sets motor power to a value between 0 and 7.

Parameters:
aPower - A value in the range [0-7].

getPower

public final int getPower()
Returns the current motor power.


forward

public final void forward()
Causes motor to rotate forward.


backward

public final void backward()
Causes motor to rotate backwards.


stop

public final void stop()
Causes motor to stop, pretty much instantaneously. In other words, the motor doesn't just stop; it will resist any further motion.


flt

public final 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.


controlMotor

public void controlMotor(int aMotor,
                         int aState)

controlMotorPower

public void controlMotorPower(int aMotor,
                              int aValue)