- Code: Select all
import lejos.navigation.*;
import lejos.nxt.*;
public class DirectionTest {
public static void main(String [] args) {
Navigator robot = new TachoNavigator(5.6F, 13.0F,Motor.C, Motor.B, false);
robot.setSpeed(450);
RobotMover b = new RobotMover();
b.north();
}
}
- Code: Select all
public class RobotMover
{
Pilot robot;
int NORTH = 0;
int SOUTH = 180;
int WEST = 270;
int EAST = 90;
int facing = 0;
public RobotMover()
{
}
/*public int facing()
{
return NORTH; //or SOUTH EAST WEST...needs a bit of thinking!
}
*/
public void north()
{
//if facing north : forward ()
if(facing == NORTH)
{
robot.travel(25);
}
//if facing south : rotate180(); forward ()
else if(facing ==SOUTH)
{
robot.rotate(180);
robot.travel(25);
}
//if facing west : rotate90Anticlockwise(); forward()
else if(facing ==WEST)
{
robot.rotate(90);
robot.travel(25);
}
//if facing east : rotate90Clockwise(); forward()
else if(facing == EAST)
{
robot.rotate(-90);
robot.travel(25);
}
}
I am having problems with above snippets to try and get the robot to move in a direction. the code compiles and links to the NXt however when i run it i get the following errors to the Lcd,
i havent seen errors on the LCD so i m stumpted
Java Exception
Class: 8
Method: 22
PC: 2215
