Guest User

Untitled

a guest
Oct 19th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include "simpletools.h" // Include simpletools header
  2. #include "adcDCpropab.h" // Include ping header
  3. #include "servo.h"
  4.  
  5. #define EMIC_TX 6
  6. #define EMIC_RX 7
  7.  
  8. int main() // main function
  9. {
  10. pause(1000);
  11. adc_init(21, 20, 19, 18);
  12. //FdSerial_Start(EMIC_RX, EMIC_TX, 0, 9600);
  13.  
  14. float lrV, udV;
  15. int ud, lr;
  16.  
  17. while(1) // Repeat indefinitely
  18. {
  19. udV = adc_volts(2);
  20. lrV = adc_volts(3);
  21.  
  22. ud = 200*(udV-2.5)/5;
  23. lr = 200*(lrV-2.5)/5;
  24.  
  25. if (ud > 10)
  26. {
  27. print("Up \n");
  28. servo_angle(16, 900);
  29. pause(3000);
  30. }
  31. else if (ud < -10)
  32. {
  33. print("Down \n");
  34. servo_angle(16, 0);
  35. pause(3000);
  36. }
  37. if (lr > 10)
  38. {
  39. print("Right \n");
  40. servo_angle(17, 900);
  41. pause(3000);
  42. }
  43. else if (lr < -10)
  44. {
  45. print("Left \n");
  46. servo_angle(16, 0);
  47. pause(3000);
  48. }
  49. pause(100);
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment