Skip to content

Instantly share code, notes, and snippets.

@isaiah7p
Created August 8, 2020 05:34
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 isaiah7p/ebd4b249566f5b0f8f81680a6d1d4164 to your computer and use it in GitHub Desktop.
Save isaiah7p/ebd4b249566f5b0f8f81680a6d1d4164 to your computer and use it in GitHub Desktop.
#include <NewPing.h>
#define TRIGGER_PIN 3
#define ECHO_PIN 2
#define MAX_DISTANCE 200
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
void setup() {
Serial.begin(9600);
}
void loop() {
delay(1000);
Serial.print("Ping CM: ");
Serial.print(sonar.ping_cm());
Serial.print("Ping In: ");
Serial.println(sonar.ping_in());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment