-
-
Save mskf1383/e76ef0ebb0cada2aac3833cf02e7b829 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int getDistance() { | |
| // reset ulterasonic | |
| digitalWrite(triggerPin, LOW); | |
| delayMicroseconds(2); | |
| // send signal | |
| digitalWrite(triggerPin, HIGH); | |
| delayMicroseconds(10); | |
| digitalWrite(triggerPin, LOW); | |
| // recive signal | |
| duration = pulseIn(echoPin, HIGH); | |
| // calculate distance | |
| return duration*0.034/2; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment