I am new here. I am French, so excuse me for me English
I am working since one week on Lego Mindstorms NXT with the leJOS API.
I have a problem. I would like to stop my robot after 10 seconds. I have try to use the currentTimeMillis fonction but I have an error when I try to link.
This is my code :
- Code: Select all
import lejos.nxt.*;
public class Time
{
public static void main(String [] args) throws Exception
{
LCD.clear();
LCD.drawString("Press ENTER", 3, 3);
LCD.refresh();
Button.ENTER.waitForPressAndRelease();
long t1 = System.currentTimeMillis();
long t2 = t1;
while( t2-t1 < 10000 );
{
t2 = System.currentTimeMillis();
LCD.clear();
LCD.drawString("Wait", 3, 3);
LCD.refresh();
}
LCD.clear();
LCD.drawString("10 seconds", 3, 3);
LCD.refresh();
}
}
I think that the problem is that "t2-t1" is long and the while loop condition works with an integer.
Maybe do you know how I could convert a long in an integer or how to solve this problem?
Thank you
BioZiK
