int Trig = 14;
int Echo = 27;
int distance;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(Trig, OUTPUT);
pinMode(Echo, INPUT);
}
void loop() {
digitalWrite(Trig, HIGH);
delay(100);
digitalWrite(Trig, LOW);
int reading = (pulseIn(Echo,HIGH));
distance = (reading * 0.034/2);
Serial.println("Ok, received");
Serial.println(distance);
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}