Advertisement
Guest User

Untitled

a guest
May 23rd, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  1. #include <NewPing.h>
  2.  
  3. #define TRIGGER_PIN  12
  4. #define ECHO_PIN     11
  5. #define MAX_DISTANCE 200
  6.  
  7. NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
  8.  
  9. void setup() {
  10.   Serial.begin(115200);
  11. }
  12.  
  13. void loop() {
  14.   delay(50);
  15.   int uS = sonar.ping();
  16.   Serial.print("Ping: ");
  17.   Serial.print(uS / US_ROUNDTRIP_CM);
  18.   Serial.println("cm");
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement