import lejos.nxt.*; import lejos.nxt.addon.*; /** * This program controls the claw's X Y location * * @author Will Gorman */ public class ClawMover { public static void main (String[] args) throws Exception { TouchSensor forward = new TouchSensor(SensorPort.PORTS[0]); TouchSensor backward = new TouchSensor(SensorPort.PORTS[1]); TouchSensor left = new TouchSensor(SensorPort.PORTS[2]); TouchSensor right = new TouchSensor(SensorPort.PORTS[3]); while (true) { if (forward.isPressed()) { Motor.A.forward(); } else if (backward.isPressed()) { Motor.A.backward(); } else { Motor.A.flt(); } if (left.isPressed()) { Motor.B.forward(); } else if (right.isPressed()) { Motor.B.backward(); } else { Motor.B.flt(); } Thread.sleep(100); } } }