Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <math.h>
  5.  
  6. #include "abdrive.h"
  7. #include "simpletext.h"
  8. #include "simpletools.h"
  9. #include "ping.h"
  10. #include "functions.h"
  11.  
  12. int main(int argc, const char* argv[])
  13. {
  14.  
  15. int path[500];
  16. for(int j = 0; j < 10; j++)
  17. {
  18. path[ j ] = 0;
  19. }
  20.  
  21. int index = 0;
  22. int temp = 0;
  23.  
  24.  
  25. drive_speed(30,30);
  26.  
  27. while(ping_cm(8) > 5)
  28. {
  29. int front = ping_cm(8);
  30.  
  31. int irLeft = 0;
  32. for(int dacVal = 0; dacVal < 160; dacVal += 2)
  33. {
  34. dac_ctr(26, 0, dacVal);
  35. freqout(11, 1, 38000);
  36. irLeft += input(10);
  37. }
  38.  
  39.  
  40. int irRight = 0;
  41. for(int dacVal = 0; dacVal < 160; dacVal += 2)
  42. {
  43. dac_ctr(27, 1, dacVal);
  44. freqout(1, 1, 38000);
  45. irRight += input(2);
  46. }
  47.  
  48. int indicator = 0;
  49. // get parameters --------------------
  50. indicator = temp - irLeft;
  51.  
  52.  
  53. if(indicator >= 0 && indicator <= 3){
  54. drive_speed(40,30);
  55. path[index] = 1;
  56. }
  57. if(indicator > 3 && indicator <= 5){
  58. drive_speed(50,30);
  59. path[index] = 2;
  60. }
  61. if(indicator < 0 && indicator >= -3){
  62. drive_speed(30,40);
  63. path[index] = 3;
  64. }
  65. if(indicator < -3 && indicator >= -5){
  66. drive_speed(30,50);
  67. path[index] = 4;
  68. }
  69.  
  70.  
  71. temp = irLeft;
  72. printf("%d %d \n", irRight, irLeft);
  73.  
  74. index++;
  75. }
  76.  
  77.  
  78. drive_speed(0, 0);
  79. drive_goto(-10,-10);
  80. degreesTurn(180);
  81.  
  82. path[index] = 0;
  83.  
  84. for(int i = index; i >= 0; i--){
  85. //stored[i] = path[index - i];
  86. //printf("%d\n", stored[i]);
  87. reversePath(path[i]);
  88. printf("%d\n", path[i]);
  89. }
  90.  
  91. drive_speed(0, 0);
  92.  
  93.  
  94.  
  95. return 0;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement