int trig = 3;
int echo = 2;
void setup() {
Serial.begin(9600)
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
}
void loop() {
digitalWrite(trig, LOW);
delay(1000);
digitalWrite(trig, HIGH);
delay(1000);
digitalWrite(LOW);
int duration = pulseIn(echo, HIGH);
int distance = (duration/2)*(0.034);
Serial.println(distance);
Serial.println(" cm");
}