Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.15 KB | None | 0 0
  1. while(actualpoint != finalpoint){
  2. switch(actualpoint){
  3.   case 0:
  4.   if(previouspoint = 15){
  5.     if(nextpoint = nextNorth){
  6.       turnRight();
  7.       delay(delayTime);
  8.     }
  9.   }
  10.   else if (previouspoint = 1){
  11.     if(nextpoint = nextEast){
  12.       turnLeft();
  13.     }
  14.   }
  15.   else{
  16.     moveForward();
  17.   }
  18.   previouspoint = 0;
  19.   break;
  20.   case 1:
  21.   if(previouspoint = 0){
  22.     if(nextpoint = nextNorth){
  23.       moveForward();
  24.     }
  25.     else if(nextpoint = nextEast){
  26.       turnRight();
  27.       }
  28.   }
  29.   else if(previouspoint = 10){
  30.     if(nextpoint = 2){
  31.       turnRight();
  32.     }
  33.     else if(nextpoint = 0){
  34.       turnLeft();
  35.       }
  36.   }
  37.   else if(previouspoint = 2){
  38.     if(nextpoint = 10){
  39.       turnLeft();
  40.     }
  41.     else if(nextpoint = 0){
  42.       moveForward();
  43.     }
  44.   }
  45.   else if(previouspoint = 10){
  46.     if(nextpoint = 2){
  47.       turnRight();
  48.     }
  49.     else if(nextpoint = 1){
  50.       turnLeft();
  51.     }
  52.   }
  53.   previouspoint = 1;
  54.   break;
  55.   case 2:
  56.   if(previouspoint = 1){
  57.     if(nextpoint = 5){
  58.       turnRight();
  59.     }
  60.     else if(nextpoint = 3){
  61.       moveForward();
  62.     }
  63.   }
  64.   else if(previouspoint = 5){
  65.     if(nextpoint = 3){
  66.       turnRight();
  67.     }
  68.     else if(nextpoint = 1){
  69.       turnLeft();      
  70.     }
  71.   }
  72.   else if(previouspoint = 3){
  73.     if(nextpoint = 5){
  74.       turnLeft();
  75.     }
  76.     else if(nextpoint = 1){
  77.       moveForward();
  78.     }
  79.   }
  80.   previouspoint = 2;
  81.   break;
  82.   case 3:
  83.   if(previouspoint = 2){
  84.     if(nextpoint = 4){
  85.       turnRight();  
  86.     }
  87.   }
  88.   else(previouspoint = 4){
  89.    if(nextpoint = 2){
  90.      turnLeft();
  91.    }
  92.   }
  93.   previouspoint = 3;
  94.   break;
  95.   case 4:
  96.   if(previouspoint = 3){
  97.     if(nextpoint = 8){
  98.       moveForward();      
  99.     }
  100.     else if(nextpoint = 5){
  101.       turnRight();
  102.     }
  103.   }
  104.   else if(previouspoint = 5){
  105.    if(nextpoint = 8){
  106.      turnRight();
  107.    }
  108.    else if(nextpoint = 3){
  109.     turnLeft();
  110.    }
  111.   }
  112.   else if(previouspoint = 8){
  113.     if(nextpoint = 5){
  114.       turnLeft();
  115.     }
  116.     else if(nextpoint = 3){
  117.       moveForward();
  118.     }
  119.   }
  120.   previouspoint = 4;
  121.   break;
  122.   case 5:
  123.   if(previouspoint = 4){
  124.     if(nextpoint = 2){
  125.       turnRight();
  126.     }
  127.     else if(nextpoint = 7){
  128.       turnLeft();
  129.     }
  130.   }
  131.   else if(previouspoint = 7){
  132.     if(nextpoint = 4){
  133.       turnRight();
  134.     }
  135.     else if(nextpoint = 2){
  136.       moveForward();
  137.     }
  138.   }
  139.   else if(previouspoint = 2){
  140.    if(nextpoint = 4){
  141.     turnLeft();
  142.    }
  143.    else if(nextpoint = 7){
  144.     moveForward();
  145.    }
  146.   }
  147.   previouspoint = 5;
  148.   break;
  149.   case 7:
  150.   if(previouspoint = 5){
  151.     if(nextpoint = 8){
  152.       turnLeft();
  153.     }
  154.   }
  155.   else if(previouspoint = 8){
  156.     if(nextpoint = 5){
  157.       turnRight();
  158.     }
  159.   }
  160.   previouspoint = 7;
  161.   break;
  162.   case 8:
  163.   if(previouspoint = 9){
  164.     if(nextpoint = 7){
  165.       turnLeft();
  166.     }
  167.     else if(nextpoint = 4){
  168.       moveForward();
  169.     }
  170.   }
  171.   else if(previouspoint = 7){
  172.     if(nextpoint = 9){
  173.       turnRight();
  174.     }
  175.     else if(nextpoint = 4){
  176.       turnLeft();
  177.     }
  178.   }
  179.   else if(previouspoint = 4){
  180.     if(nextpoint = 9){
  181.       moveForward();
  182.     }
  183.     else if(nextpoint = 7){
  184.       turnRight();
  185.     }
  186.   }
  187.   previouspoint = 8;
  188.   break;
  189.   case 9:
  190.   if(previouspoint = 8){
  191.     if(nextpoint = 10){
  192.       turnRight();
  193.     }
  194.     else if(nextpoint = 14){
  195.       moveForward();
  196.     }
  197.   }
  198.   else if(previouspoint = 10){
  199.     if(nextpoint = 14){
  200.       turnRight(),  
  201.     }
  202.     else if(nextpoint = 8){
  203.       turnLeft();
  204.     }
  205.   }
  206.   else if(previouspoint = 14){
  207.     if(nextpoint = 10){
  208.       turnLeft();
  209.     }
  210.     else if(nextpoint = 8){
  211.       moveForward();
  212.     }
  213.   }
  214.   previouspoint = 9;
  215.   break;
  216.   case 10:
  217.   if(previouspoint = 9){
  218.     if(nextpoint = 13){
  219.       turnLeft();
  220.     }
  221.     else if(nextpoint = 11){
  222.       moveForward();
  223.     }
  224.     else if(nextpoint = 1){
  225.       turnRight();
  226.     }
  227.   }
  228.   else if(previouspoint = 13){
  229.     if(nextpoint = 9){
  230.       turnRight();
  231.     }
  232.     else if(nextpoint = 11){
  233.       turnLeft();
  234.     }
  235.     else if(nextpoint = 1){
  236.       moveForward();
  237.     }
  238.   }
  239.   else if(previouspoint = 11){
  240.     if(nextpoint = 9){
  241.       moveForward();
  242.     }
  243.     else if(nextpoint = 13){
  244.       turnRight();
  245.     }
  246.     else if(nextpoint = 1){
  247.       turnLeft();
  248.     }
  249.   }
  250.   else if(previouspoint = 1){
  251.     if(nextpoint = 11){
  252.       turnRight();
  253.     }
  254.     else if(nextpoint = 13){
  255.       moveForward();
  256.     }
  257.     else if(nextpoint = 9){
  258.       turnLeft();
  259.     }
  260.   }
  261.   previouspoint = 10;
  262.   break;
  263.   case 11:
  264.   if(previouspoint = 10){
  265.     if(nextpoint = 6){
  266.       turnRight();
  267.     }
  268.   }
  269.   else if(previouspoint = 6){
  270.     if(nextpoint = 10){
  271.       turnLeft();
  272.     }
  273.   }
  274.   previouspoint = 11;
  275.   break;
  276.   case 12:
  277.   if(previouspoint = 13){
  278.     if(nextpoint = 15){
  279.       turnRight();
  280.     }
  281.   }
  282.   else if(previouspoint = 15){
  283.     if(nextpoint = 13){
  284.       turnLeft();
  285.     }
  286.   }
  287.   previouspoint = 12;
  288.   break;
  289.   case 13:
  290.   if(previouspoint = 10){
  291.     if(nextpoint = 14){
  292.       turnLeft();
  293.     }
  294.     else if(nextpoint = 12){
  295.       turnRight();
  296.     }
  297.   }
  298.   else if(previouspoint = 14){
  299.     if(nextpoint = 10){
  300.       turnRight();
  301.     }
  302.     else if(nextpoint = 12){
  303.       moveForward();
  304.     }
  305.   }
  306.   else if(previouspoint = 12){
  307.     if(nextpoint = 10){
  308.       turnLeft();
  309.     }
  310.     else if(nextpoint = 14){
  311.       moveForward();
  312.     }
  313.   }
  314.   previouspoint = 13;
  315.   break;
  316.   case 14:
  317.   if(previouspoint = 9){
  318.     if(nextpoint = 13){
  319.       turnRight();
  320.     }
  321.   }
  322.   else if(previouspoint = 13){
  323.     if(nextpoint = 9){
  324.       turnLeft();
  325.     }
  326.   }
  327.   previouspoint = 14;
  328.   break;
  329.   case 15:
  330.   if(previouspoint = 0){
  331.     if(nextpoint = 6){
  332.       turnLeft();
  333.     }
  334.     else if(nextpoint = 12){
  335.       moveForward();
  336.     }
  337.   }
  338.   else if(previouspoint = 6){
  339.     if(nextpoint = 0){
  340.       turnRight();
  341.     }
  342.     else if(nextpoint = 12){
  343.       turnLeft();
  344.     }
  345.   }
  346.   else if(previouspoint = 12){
  347.     if(nextpoint = 0){
  348.       moveForward();
  349.     }
  350.     else if(nextpoint = 6){
  351.       turnRight();
  352.     }
  353.   }
  354.   previouspoint = 15;
  355.   break;
  356. }
  357. else{
  358.   Motor.stop(MOTOR1);
  359.   Motor.stop(MOTOR2);
  360.   Serial.print("Vous êtes arrivés!")
  361. }
  362. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement