const int trig = 7;
const int echo = 6;
void setup() {
// put your setup code here, to run once:
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(trig, HIGH);
delayMicroseconds(20);
digitalWrite(trig, LOW);
unsigned long dueration = pulseIn(echo, HIGH);
float distance = dueration * 0.033 / 2.0;
Serial.println(distance);
delay(200);
}