Advertisement
Guest User

Untitled

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