Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Authors: Esteban, Robert
- Assignment: Project 4
- Date: 3/25/15
- Description: Robot drives forwa
- */
- import lejos.nxt.*;
- import lejos.robotics.navigation.DifferentialPilot;
- public class project5 //make sure the classname matches the filename (case-sensitive)
- {
- private DifferentialPilot bot; //field declaration for a DifferentialPilot object
- //the code in the main method will not change (except for the classname)
- public static void main(String[] args)
- {
- project5 myProgram = new project5(); //matches classname (case-sensitive)
- myProgram.run();
- }//main()
- //the constructor generally instantiates field objects and sets other initial state information
- public project5() //matches classname (case-sensitive)
- {
- bot = new DifferentialPilot(56, 108, Motor.B, Motor.C); //instantiate a DifferentialPilot object named "bot"
- }//constructor
- //your code goes in this method
- public void run()
- {
- bot.travel(1550); //good
- bot.rotate(-110); //good
- bot.travel(1000); //good
- bot.rotate(-150); //good
- bot.travel(1250); //good
- bot.rotate(90); //good
- bot.travel(1100); //good
- bot.rotate(-150); //good
- bot.travel(1000); //good
- bot.rotate(400); //Start Celebration !!!!
- bot.rotate(-400);
- bot.rotate(400);
- bot.rotate(-400);
- }//run()
- //the following method writes a string to the screen. Useful for debugging.
- public void displayString(String msg)
- {
- LCD.clear();
- LCD.drawString(msg, 0, 0); //writes the msg to the screen
- LCD.refresh();
- }//displayString()
- //the following method writes an int (whole number) to the screen. Useful for debugging.
- public void displayInt(int num)
- {
- LCD.clear();
- LCD.drawInt(num, 4, 0, 0); //writes the num to the screen
- LCD.refresh();
- } //displayInt
- //the following method allows the bot to do what it was doing, but suspends execution of the
- //next statement. When this method returns, the program continues executing where it left off.
- public void pause(int milli)
- {
- try
- {
- Thread.sleep(milli);
- }//try
- catch(InterruptedException e)
- {
- }//catch
- }//sleep()
- }//class project5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement