int trig = 27;
int echo = 26;
int distance;
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,HIGH);
delay(100);
digitalWrite(trig,LOW);
int reading = pulseIn(echo,HIGH);
distance = (reading * 0.034/2);
Serial.println(distance);
delay(10);
// put your main code here, to run repeatedly:
// this speeds up the simulation
}