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