All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lejos.hardware.motor.Motor Maven / Gradle / Ivy

Go to download

leJOS (pronounced like the Spanish word "lejos" for "far") is a tiny Java Virtual Machine. In 2013 it was ported to the LEGO EV3 brick.

The newest version!
package lejos.hardware.motor;

import lejos.hardware.BrickFinder;

/**
 * Motor class contains 3 instances of regulated motors.
 * 

* Example:

*

 *   Motor.A.setSpeed(720);// 2 RPM
 *   Motor.C.setSpeed(720);
 *   Motor.A.forward();
 *   Motor.C.forward();
 *   Thread.sleep (1000);
 *   Motor.A.stop();
 *   Motor.C.stop();
 *   Motor.A.rotateTo( 360);
 *   Motor.A.rotate(-720,true);
 *   while(Motor.A.isMoving() :Thread.yield();
 *   int angle = Motor.A.getTachoCount(); // should be -360
 *   LCD.drawInt(angle,0,0);
 * 
* @author Roger Glassey/Andy Shaw */ public class Motor { /** * Motor A. */ public static final NXTRegulatedMotor A = new NXTRegulatedMotor(BrickFinder.getDefault().getPort("A")); /** * Motor B. */ public static final NXTRegulatedMotor B = new NXTRegulatedMotor(BrickFinder.getDefault().getPort("B")); /** * Motor C. */ public static final NXTRegulatedMotor C = new NXTRegulatedMotor(BrickFinder.getDefault().getPort("C")); /** * Motor D. */ public static final NXTRegulatedMotor D = new NXTRegulatedMotor(BrickFinder.getDefault().getPort("D")); private Motor() { // Motor class cannot be instantiated } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy