Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- long duration,cm;
- void setup(){
- pinMode(10, OUTPUT);
- pinMode(11, INPUT);
- Serial.begin(9600);
- }
- void loop(){
- digitalWrite(11, LOW);
- delayMicroseconds(2);
- digitalWrite(11, HIGH);
- delayMicroseconds(10);
- digitalWrite(11, LOW);
- duration = pulseIn(11, HIGH);
- cm=duration/29/2;
- Serial.print(cm);
- Serial.print("cm");
- Serial.println();
- delay(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement