Advertisement
Guest User

Untitled

a guest
Oct 12th, 2013
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. /*
  2. Test Ping Distance.c
  3.  
  4. Version 0.94 for use with SimpleIDE 9.40 and its Simple Libraries
  5.  
  6. Measure and display Ping))) Ultrasonic Distance Sensor distance measurements.
  7.  
  8. http://learn.parallax.com/propeller-c-simple-devices/sense-distance-ping
  9. */
  10.  
  11. #include "simpletools.h" // Include simpletools header
  12. #include "ping.h" // Include ping header
  13.  
  14. int main() // main function
  15. {
  16. while(1) // Repeat indefinitely
  17. {
  18. int cmDist = ping_cm(15); // Get cm distance from Ping)))
  19. print("cmDist = %d\n", cmDist); // Display distance
  20. pause(200); // Wait 1/5 second
  21.  
  22. if(cmDist > 25) cmDist = 25;
  23. cmDist = 25 - cmDist;
  24. cmDist = cmDist * 10;
  25. dac_ctr(27, 1, cmDist);
  26.  
  27. pause(200);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement