Skip to content

Instantly share code, notes, and snippets.

@ddefb
Created March 5, 2019 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddefb/32b408f8bfb452720b73a7d4cfc9ecb7 to your computer and use it in GitHub Desktop.
Save ddefb/32b408f8bfb452720b73a7d4cfc9ecb7 to your computer and use it in GitHub Desktop.
double read_obstacle(){
digitalWrite(A0, HIGH);
delayMicroseconds(15);
digitalWrite(A0, LOW);
uint32_t pulse_time = pulseIn(A1, HIGH);
double distance = 0.01715 * pulse_time;
return distance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment