The NXT can control up to three motors connected to interfaces A, B and/or C. The Motor class provides three static instances - one for each each motor interface - namely A, B and C.
To rotate the motor either forward or backwards (relative to the rear of the motor - where the cable is attached) call the appropriate method forward() or backward() on the motor instance accordingly.
For example to rotate motor A forward do the following.
Motor.A.forward();
To rotate motor B backwards do the following.
Motor.B.backward();
Following an instruction to rotate forward or backwards the motors will continue to rotate indefinitely.
To stop motor C do the following.
Motor.C.stop();
To use the Motor classes import the following package.
import lejos.Motor
References
http://lejos.sourceforge.net/nxt/nxj/api/index.html
No comments:
Post a Comment