Advertisement
Guest User

Untitled

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