Skip to content

Instantly share code, notes, and snippets.

@ruisantos16
Created November 25, 2013 21:26
Show Gist options
  • Save ruisantos16/7649175 to your computer and use it in GitHub Desktop.
Save ruisantos16/7649175 to your computer and use it in GitHub Desktop.
#include
#define TRIGGER_PIN 12
#define ECHO_PIN 11
#define MAX_DISTANCE 200
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
void setup() {
Serial.begin(9600);
}
void loop() {
delay(50);
unsigned int uS = sonar.ping_cm();
Serial.print(uS);
Serial.println(“cm”);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment