Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while(actualpoint != finalpoint){
- switch(actualpoint){
- case 0:
- if(previouspoint = 15){
- if(nextpoint = nextNorth){
- turnRight();
- delay(delayTime);
- }
- }
- else if (previouspoint = 1){
- if(nextpoint = nextEast){
- turnLeft();
- }
- }
- else{
- moveForward();
- }
- previouspoint = 0;
- break;
- case 1:
- if(previouspoint = 0){
- if(nextpoint = nextNorth){
- moveForward();
- }
- else if(nextpoint = nextEast){
- turnRight();
- }
- }
- else if(previouspoint = 10){
- if(nextpoint = 2){
- turnRight();
- }
- else if(nextpoint = 0){
- turnLeft();
- }
- }
- else if(previouspoint = 2){
- if(nextpoint = 10){
- turnLeft();
- }
- else if(nextpoint = 0){
- moveForward();
- }
- }
- else if(previouspoint = 10){
- if(nextpoint = 2){
- turnRight();
- }
- else if(nextpoint = 1){
- turnLeft();
- }
- }
- previouspoint = 1;
- break;
- case 2:
- if(previouspoint = 1){
- if(nextpoint = 5){
- turnRight();
- }
- else if(nextpoint = 3){
- moveForward();
- }
- }
- else if(previouspoint = 5){
- if(nextpoint = 3){
- turnRight();
- }
- else if(nextpoint = 1){
- turnLeft();
- }
- }
- else if(previouspoint = 3){
- if(nextpoint = 5){
- turnLeft();
- }
- else if(nextpoint = 1){
- moveForward();
- }
- }
- previouspoint = 2;
- break;
- case 3:
- if(previouspoint = 2){
- if(nextpoint = 4){
- turnRight();
- }
- }
- else(previouspoint = 4){
- if(nextpoint = 2){
- turnLeft();
- }
- }
- previouspoint = 3;
- break;
- case 4:
- if(previouspoint = 3){
- if(nextpoint = 8){
- moveForward();
- }
- else if(nextpoint = 5){
- turnRight();
- }
- }
- else if(previouspoint = 5){
- if(nextpoint = 8){
- turnRight();
- }
- else if(nextpoint = 3){
- turnLeft();
- }
- }
- else if(previouspoint = 8){
- if(nextpoint = 5){
- turnLeft();
- }
- else if(nextpoint = 3){
- moveForward();
- }
- }
- previouspoint = 4;
- break;
- case 5:
- if(previouspoint = 4){
- if(nextpoint = 2){
- turnRight();
- }
- else if(nextpoint = 7){
- turnLeft();
- }
- }
- else if(previouspoint = 7){
- if(nextpoint = 4){
- turnRight();
- }
- else if(nextpoint = 2){
- moveForward();
- }
- }
- else if(previouspoint = 2){
- if(nextpoint = 4){
- turnLeft();
- }
- else if(nextpoint = 7){
- moveForward();
- }
- }
- previouspoint = 5;
- break;
- case 7:
- if(previouspoint = 5){
- if(nextpoint = 8){
- turnLeft();
- }
- }
- else if(previouspoint = 8){
- if(nextpoint = 5){
- turnRight();
- }
- }
- previouspoint = 7;
- break;
- case 8:
- if(previouspoint = 9){
- if(nextpoint = 7){
- turnLeft();
- }
- else if(nextpoint = 4){
- moveForward();
- }
- }
- else if(previouspoint = 7){
- if(nextpoint = 9){
- turnRight();
- }
- else if(nextpoint = 4){
- turnLeft();
- }
- }
- else if(previouspoint = 4){
- if(nextpoint = 9){
- moveForward();
- }
- else if(nextpoint = 7){
- turnRight();
- }
- }
- previouspoint = 8;
- break;
- case 9:
- if(previouspoint = 8){
- if(nextpoint = 10){
- turnRight();
- }
- else if(nextpoint = 14){
- moveForward();
- }
- }
- else if(previouspoint = 10){
- if(nextpoint = 14){
- turnRight(),
- }
- else if(nextpoint = 8){
- turnLeft();
- }
- }
- else if(previouspoint = 14){
- if(nextpoint = 10){
- turnLeft();
- }
- else if(nextpoint = 8){
- moveForward();
- }
- }
- previouspoint = 9;
- break;
- case 10:
- if(previouspoint = 9){
- if(nextpoint = 13){
- turnLeft();
- }
- else if(nextpoint = 11){
- moveForward();
- }
- else if(nextpoint = 1){
- turnRight();
- }
- }
- else if(previouspoint = 13){
- if(nextpoint = 9){
- turnRight();
- }
- else if(nextpoint = 11){
- turnLeft();
- }
- else if(nextpoint = 1){
- moveForward();
- }
- }
- else if(previouspoint = 11){
- if(nextpoint = 9){
- moveForward();
- }
- else if(nextpoint = 13){
- turnRight();
- }
- else if(nextpoint = 1){
- turnLeft();
- }
- }
- else if(previouspoint = 1){
- if(nextpoint = 11){
- turnRight();
- }
- else if(nextpoint = 13){
- moveForward();
- }
- else if(nextpoint = 9){
- turnLeft();
- }
- }
- previouspoint = 10;
- break;
- case 11:
- if(previouspoint = 10){
- if(nextpoint = 6){
- turnRight();
- }
- }
- else if(previouspoint = 6){
- if(nextpoint = 10){
- turnLeft();
- }
- }
- previouspoint = 11;
- break;
- case 12:
- if(previouspoint = 13){
- if(nextpoint = 15){
- turnRight();
- }
- }
- else if(previouspoint = 15){
- if(nextpoint = 13){
- turnLeft();
- }
- }
- previouspoint = 12;
- break;
- case 13:
- if(previouspoint = 10){
- if(nextpoint = 14){
- turnLeft();
- }
- else if(nextpoint = 12){
- turnRight();
- }
- }
- else if(previouspoint = 14){
- if(nextpoint = 10){
- turnRight();
- }
- else if(nextpoint = 12){
- moveForward();
- }
- }
- else if(previouspoint = 12){
- if(nextpoint = 10){
- turnLeft();
- }
- else if(nextpoint = 14){
- moveForward();
- }
- }
- previouspoint = 13;
- break;
- case 14:
- if(previouspoint = 9){
- if(nextpoint = 13){
- turnRight();
- }
- }
- else if(previouspoint = 13){
- if(nextpoint = 9){
- turnLeft();
- }
- }
- previouspoint = 14;
- break;
- case 15:
- if(previouspoint = 0){
- if(nextpoint = 6){
- turnLeft();
- }
- else if(nextpoint = 12){
- moveForward();
- }
- }
- else if(previouspoint = 6){
- if(nextpoint = 0){
- turnRight();
- }
- else if(nextpoint = 12){
- turnLeft();
- }
- }
- else if(previouspoint = 12){
- if(nextpoint = 0){
- moveForward();
- }
- else if(nextpoint = 6){
- turnRight();
- }
- }
- previouspoint = 15;
- break;
- }
- else{
- Motor.stop(MOTOR1);
- Motor.stop(MOTOR2);
- Serial.print("Vous êtes arrivés!")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement