Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Test Ping Distance.c
- Version 0.94 for use with SimpleIDE 9.40 and its Simple Libraries
- Measure and display Ping))) Ultrasonic Distance Sensor distance measurements.
- http://learn.parallax.com/propeller-c-simple-devices/sense-distance-ping
- */
- #include "simpletools.h" // Include simpletools header
- #include "ping.h" // Include ping header
- int main() // main function
- {
- while(1) // Repeat indefinitely
- {
- int cmDist = ping_cm(15); // Get cm distance from Ping)))
- print("cmDist = %d\n", cmDist); // Display distance
- pause(200); // Wait 1/5 second
- if(cmDist > 25) cmDist = 25;
- cmDist = 25 - cmDist;
- cmDist = cmDist * 10;
- dac_ctr(27, 1, cmDist);
- pause(200);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement