int trig = 14;
int echo = 12;
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);
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(trig, HIGH);
delay(100);
digitalWrite(trig, LOW);
int reading = pulseIn(echo,HIGH);
distance = (reading*0.034/2)+1;
Serial.println(distance);
if(distance > 200)
digitalWrite(13, HIGH);
else
digitalWrite(13, LOW);
// put your main code here, to run repeatedly:
// this speeds up the simulation
}