int trig = 11;
int echo = 10;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(trig, LOW);
delayMicroseconds(2);
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
long dis = pulseIn(echo,HIGH);
Serial.println((dis*0.0342)/2);
delay(300);
}