Advertisement
KRITSADA

IPST-SE Track Compass Stop with Time

Apr 16th, 2018
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. // เคลื่อนที่ไปในทิศทางที่ต้องการด้วยเข็มทิศ หยุดการเคลื่อนที่ด้วยเวลา
  2. #include <ipst.h>  
  3.   void trackc_t(int c, float time) //แทร็กเข็มทิศ หยุดด้วยเวลา
  4.   {
  5.     float t;
  6.     t = 0;
  7.     compass_readConfig();
  8.     while (1)
  9.     {
  10.       if (time < t)
  11.       {        break;      }
  12.       else if (compass_read() <= c + 2 && compass_read() >= c - 2)
  13.       {       fd(50); t = t + 0.1;      }
  14.  
  15.       else if (compass_read() < c + 2)
  16.       {        sr(30); t = t + 0.1;      }
  17.       else if (compass_read() > c - 2)
  18.       {        sl(30); t = t + 0.1;      }
  19.     }
  20.   }
  21. void left_c(int c)
  22. {
  23.   compass_readConfig();
  24.   while (compass_read() > c)
  25.   {
  26.   sl(40);
  27.   }
  28. }
  29. void right(int c)
  30.   {
  31.  
  32.   compass_readConfig();
  33.   while (compass_read() < c)
  34.   {
  35.    sr(40);
  36.   }
  37. }
  38.  
  39.  
  40.  
  41. void setup() {
  42.      compass_readConfig();
  43.     compass_factoryReset();
  44.  
  45. }
  46.  
  47. void loop() {
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement