Hi !
I want to set the speed (max) of my motor once and for all my program.
The following code is not working :
import lejos.nxt.*;
public class MonRobot implements ButtonListener {
NXTRegulatedMotor motorB = Motor.B;
NXTRegulatedMotor motorC = Motor.C;
public void MonRobot() {
motorB.setSpeed(900);
motorC.setSpeed(900);
}
public void avance() {
/*Motor.B.setSpeed(900);
Motor.C.setSpeed(900);*/
Motor.B.forward();
Motor.C.forward();
}
public void recule() {
Motor.B.backward();
Motor.C.backward();
}
public void tourne() {
Motor.B.forward();
}
public void buttonPressed(Button b) {
}
public void buttonReleased(Button b) {
System.exit(0);
}
public static void main(String[] args) throws Exception {
MonRobot robot = new MonRobot();
Button.ESCAPE.addButtonListener(robot);
TouchSensor capteur = new TouchSensor(SensorPort.S1);
robot.avance();
while(true) {
if (capteur.isPressed()) {
robot.recule();
Thread.sleep(1000);
robot.tourne();
Thread.sleep(500);
robot.avance();
System.out.println("Sortie de boucle");
}
}
}
}
Sorry for the french in the code...
The red part doesn't give the behavior expected.
If i suppress comments, the green code is giving me the behavior i want.
Why ? Thx in advance.
