Skip to content

Instantly share code, notes, and snippets.

@jonchen727
Last active October 12, 2017 22:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
#include <NewPing.h>
#define TRIGGER_PIN 3
#define ECHO_PIN 4
#define MAX_DISTANCE 200
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
void setup() {
Serial.begin(115200);
}
void loop() {
delay(50);
Serial.println((0.034027/2)*sonar.ping_median(10));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment