int trig =13;
int echo =27;
long Distance , Duriation;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
Serial.println("Hello, ESP32!");
}
void loop() {
digitalWrite(trig,LOW);
delayMicroseconds(2);
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
Duriation = pulseIn(echo,HIGH);
Distance = (Duriation * 0.034)/2+1;
Serial.println(Distance);
// put your main code here, to run repeatedly:
delay(300); // this speeds up the simulation
}