I'm making a set way and everything works but one thing.
the robot won't glance itself good enough
i have no idea why?
i have the motors at the right speed got the code nd everything but why ?
Thanks this is my code :
- Code: Select all
import lejos.nxt.*;
import lejos.util.Delay;
public class Segway {
public static void Balance() {
ColorSensor light = new ColorSensor(SensorPort.S1);
int lightVal = 0;
lightVal = light.getLightValue();
Motor.A.setSpeed(990);
Motor.B.setSpeed(990);
while(true) {
while(lightVal < light.getLightValue()) {
Motor.A.forward();
Motor.B.forward();
}
while(lightVal > light.getLightValue()) {
Motor.A.backward();
Motor.B.backward();
}
}
}
public static void main(String[] args) throws Exception {
Button.waitForPress();
Sound.beep();
Delay.msDelay(1500);
Sound.beep();
Delay.msDelay(1500);
Sound.beep();
Delay.msDelay(1500);
Sound.twoBeeps();
Balance();
Button.waitForPress();
}
}
EDIT:: would an admin please move this to software? i accidentally putted in the hardware topics
