Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include "NewPing.h"
#define TRIGpin 2
#define ECHOpin 3
#define MaxDistance 200
NewPing m(TRIGpin, ECHOpin, MaxDistance);
void setup() {
Serial.begin(9600);
}
void loop() {
delay(100);
int us = m.ping();
if (us>0) {
Serial.print(m.convert_cm(us));
Serial.println("cm");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.