SHARE
TWEET

Untitled

a guest Nov 22nd, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. long duration,cm;
  2. void setup()
  3. {
  4.   pinMode(11, OUTPUT);
  5.   pinMode(10, INPUT);
  6.   Serial.begin(9600);
  7. }
  8.  
  9. void loop()
  10. {
  11.   digitalWrite(11, LOW);
  12.   delayMicroseconds(2);
  13.   digitalWrite(11, HIGH);
  14.   delayMicroseconds(10);
  15.   digitalWrite(11, LOW);
  16.   duration = pulseIn(10,HIGH);
  17.   cm=duration/29/2;
  18.   Serial.print(cm);
  19.   Serial.print("cm");
  20.   Serial.println();
  21.   delay(500);
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top