import lejos.nxt.*; import lejos.util.*; /** experiment with speed regulation in keeping motors synchronized @author Glassey (lejos.org) @author adapted by Sharon Tuttle @author impl'd by YOUR NAMES @version 2015-02-10 */ public class GoStraight1 { /** experiment with speed regulation in keeping two motors synchronized @param args not used */ public static void main(String[] args) { System.out.println("Motor Synch Play"); Button.waitForAnyPress(); LCD.clear(); int currSpeed = 360; Motor.B.setSpeed(currSpeed); Motor.C.setSpeed(currSpeed); Motor.B.rotate(1440, true); Motor.C.rotate(1440, true); // wait 5 seconds -- to give time for // the regulator-thread controlled // rotation to end -- THEN check // tachometers for each motor Delay.msDelay(5000); LCD.drawString("B: " + Motor.B.getTachoCount(), 0, 0); LCD.drawString("c: " + Motor.C.getTachoCount(), 0, 1); Button.waitForAnyPress(); // NOW set them rotating again, and print // the tachometer counts about every // 200 milliseconds -- SEE how close // they stay; LCD.clear(); Motor.B.rotate(1440, true); Motor.C.rotate(1440, true); for (int i=0; i<8; i++) { Delay.msDelay(200); LCD.drawString("B: " + Motor.B.getTachoCount(), 0, i); LCD.drawString("C: " + Motor.C.getTachoCount(), 9, i); } Button.waitForAnyPress(); } }