int trigger=4;
int echo=5;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(trigger, OUTPUT);
pinMode(echo, INPUT);
}
int finding_distance(){
digitalWrite(trigger, HIGH);
delay(100);
digitalWrite(trigger, LOW);
float a=pulseIn(echo, HIGH);
return(a*0.034/2);
}
void loop() {
int distance=finding_distance();
Serial.println(distance);
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}