Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- long ping() {
- long duration;
- // clear ping pin
- digitalWrite(pingPin, LOW);
- delayMicroseconds(2);
- digitalWrite(pingPin, HIGH);
- delayMicroseconds(10);
- digitalWrite(pingPin, LOW);
- duration = pulseIn(echoPin, HIGH);
- return duration;
- }
- // Helper function to return the distance to an object
- // detected by the ultrasonic sensor in centimeters.
- long msToCm(long microseconds) {
- return microseconds * .034 / 2;
- }
Add Comment
Please, Sign In to add comment