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