Moderators: roger, 99jonathan, imaqine
motor.rotate(360, true);motor.rotate(360);import lejos.nxt.Motor;
import lejos.robotics.RegulatedMotor;
public class TestResetTacho {
private RegulatedMotor motor;
public TestResetTacho() {
super();
motor = Motor.A;
motor.setSpeed(200);
}
public void run() throws InterruptedException {
System.out.println("Rotate 360 grades");
motor.rotate(360, true);
//If you comment the previous line and uncomment the following one,
//a NullPointerException is thrown in the class RemoteMotor, line 190
//motor.rotate(360);
System.out.println("Tacho counter at t1: " + motor.getTachoCount());
System.out.println("Wait for a while...");
Thread.sleep(5000);
System.out.println("Reset tacho counter");
motor.resetTachoCount();
System.out.println("Tacho counter at t2: " + motor.getTachoCount());
}
/**
* @param args
*/
public static void main(String[] args) {
TestResetTacho test = new TestResetTacho();
try {
test.run();
} catch (Exception e) {
e.printStackTrace();
}
}
}
//try to reach limit
RemoteMotor.forward();
while(!TouchSensor.isPressed()){
try {Thread.sleep(50);} catch (InterruptedException e) {}
}
RemoteMotor.stop(false);
RemoteMotor.resetTachoCount(); // that's when it happensUsers browsing this forum: No registered users and 2 guests