Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import lejos.nxt.*;
- import lejos.navigation.*;
- public class centripeda{
- public static void main (String args[]) throws InterruptedException{
- Pilot pilot = new Pilot(2.12f,6.06f,Motor.A, Motor.B);
- boolean start = false;
- int speed = 300;
- Button.ENTER.waitForPressAndRelease();
- while(!Button.ENTER.isPressed()){
- LCD.drawString("Spd: "+speed,1,1);
- if(Button.LEFT.isPressed()){
- Button.LEFT.waitForPressAndRelease();
- if(speed>300){
- speed=speed-30;
- }
- }if(Button.RIGHT.isPressed()){
- Button.RIGHT.waitForPressAndRelease();
- if(speed<900){
- speed=speed+30;
- }
- }
- } pilot.setSpeed(speed);
- int vueltas = 3;
- Button.ENTER.waitForPressAndRelease();
- while(!Button.ENTER.isPressed()){
- LCD.drawString("Lap: "+vueltas,1,2);
- if(Button.LEFT.isPressed()){
- Button.LEFT.waitForPressAndRelease();
- if(vueltas>1){
- vueltas=vueltas-1;
- }
- }if(Button.RIGHT.isPressed()){
- Button.RIGHT.waitForPressAndRelease();
- if(vueltas<9){
- vueltas=vueltas+1;
- }
- }
- }
- Button.ENTER.waitForPressAndRelease();
- Motor.C.setSpeed(900);
- boolean notExit = true;
- pilot.rotate(360*vueltas,true);
- while (notExit){
- LCD.drawString("Turn: "+pilot.getTurnRatio(),1,3);
- if(pilot.getAngle()>(360*vueltas-15)){
- Motor.C.rotateTo(45);
- notExit=false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement