Here is my code:
- Code: Select all
public static void main(String[] args) {
NXTMMX mux = new NXTMMX(SensorPort.S2);
MMXRegulatedMotor motor1 = new MMXRegulatedMotor(mux, NXTMMX.MMX_MOTOR_1);
MMXRegulatedMotor motor2 = new MMXRegulatedMotor(mux, NXTMMX.MMX_MOTOR_2);
UltrasonicSensor sonic = new UltrasonicSensor(SensorPort.S3);
TouchSensor touch_fwd = new TouchSensor(SensorPort.S1);
sonic.continuous();
while(sonic.getDistance()<10){
LCD.drawInt(sonic.getDistance(), 0, 0);
motor1.setSpeed(speed);
motor1.forward();
}
motor1.stop();
Motor.A.setSpeed(speed);
Motor.A.forward();
Delay.msDelay(DELAY);
Motor.A.stop();
}
When my code reached the line "motor1.stop()", it was hang. I guested this is because the signal could not come back the NXT brick.
Anyone has ever got the same situation like me before? Or if anyone has any idea to fix this problem, pls help me.
Thanks a lot.
