Advertisement
Garro

NXT - Movimiento circular

Jan 18th, 2012
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.30 KB | None | 0 0
  1. import lejos.nxt.*;
  2. import lejos.navigation.*;
  3. public class centripeda{   
  4. public static void main (String args[]) throws InterruptedException{
  5.     Pilot pilot = new Pilot(2.12f,6.06f,Motor.A, Motor.B);
  6.     boolean start = false;
  7.     int speed = 300;
  8.     Button.ENTER.waitForPressAndRelease();
  9.     while(!Button.ENTER.isPressed()){
  10.         LCD.drawString("Spd: "+speed,1,1);
  11.         if(Button.LEFT.isPressed()){
  12.             Button.LEFT.waitForPressAndRelease();
  13.             if(speed>300){
  14.                 speed=speed-30;
  15.             }
  16.         }if(Button.RIGHT.isPressed()){
  17.             Button.RIGHT.waitForPressAndRelease();
  18.             if(speed<900){
  19.                 speed=speed+30;
  20.             }
  21.         }
  22.     }   pilot.setSpeed(speed);
  23.     int vueltas = 3;
  24.     Button.ENTER.waitForPressAndRelease();
  25.     while(!Button.ENTER.isPressed()){
  26.         LCD.drawString("Lap: "+vueltas,1,2);
  27.         if(Button.LEFT.isPressed()){
  28.             Button.LEFT.waitForPressAndRelease();
  29.             if(vueltas>1){
  30.                 vueltas=vueltas-1;
  31.             }
  32.         }if(Button.RIGHT.isPressed()){
  33.             Button.RIGHT.waitForPressAndRelease();
  34.             if(vueltas<9){
  35.                 vueltas=vueltas+1;
  36.             }
  37.         }
  38.     }
  39.     Button.ENTER.waitForPressAndRelease();
  40.     Motor.C.setSpeed(900);
  41.     boolean notExit = true;
  42.     pilot.rotate(360*vueltas,true);
  43.     while (notExit){
  44.         LCD.drawString("Turn: "+pilot.getTurnRatio(),1,3);
  45.         if(pilot.getAngle()>(360*vueltas-15)){
  46.             Motor.C.rotateTo(45);
  47.             notExit=false;
  48.         }
  49.     }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement