package RCX2; import josx.platform.rcx.*; /** *holds methods to make the rcx go. */ public class Pilot{ public static Motor engine = Motor.A; private static Motor steering = Motor.B; public static Servo steer; /** *Initializes motors. */ public static void init(){ setupServo(); } /** *Reverses for a specified time w/ a specified power. *@param msecs the number of milliseconds to reverse for, 0=until further notice. * power the speed at which to reverse (0-7). */ public static void reverse(int msecs, int power){ try{ engine.setPower(power); if(msecs > 0){ engine.backward(); Thread.sleep(msecs); engine.stop(); }else if (msecs == 0){ engine.backward(); } }catch (InterruptedException ie) {} }//reverse /** *Moves the RCX forward for a specified time and w/ a specified power. *@param msecs the number of milliseconds to reverse for, 0=until further notice. * power the speed at which to reverse (0-7). */ public static void forward(int msecs, int power){ try{ engine.setPower(power); if(msecs > 0){ engine.forward(); Thread.sleep(msecs); engine.stop(); }else if (msecs == 0){ engine.forward(); } }catch (InterruptedException ie) {} }//forward private static void setupServo(){ TextLCD.print("SetF"); try{Button.VIEW.waitForPressAndRelease(); }catch (Exception e){} steer = new Servo(Sensor.S2, Pilot.steering); } }//Pilot