Last active
October 12, 2017 22:28
-
-
Save jonchen727/e994fbfd1b77a7d6c823f0f4bf9a2adb to your computer and use it in GitHub Desktop.
This file contains 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
#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