6677

Untitled

Aug 20th, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #define trigpin 3
  2.  
  3. #define echopin 2
  4.  
  5. void setup()
  6.  
  7. {
  8.  
  9. Serial.begin(9600);
  10.  
  11. pinMode(trigpin,OUTPUT);
  12.  
  13. pinMode(echopin, INPUT);
  14.  
  15.  
  16.  
  17. }
  18.  
  19. void loop()
  20.  
  21. {
  22.  
  23. int distance, duration; //I even tried putting long instead of int
  24.  
  25. digitalWrite(trigpin,HIGH);
  26.  
  27. delayMicroseconds(10);
  28.  
  29. digitalWrite(trigpin,LOW);
  30.  
  31. while (digitalRead(echopin) == LOW) {
  32. //the controller will do nothing until the echo pin pauses
  33. }
  34.  
  35. Serial.println("Clear");
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment