int IRSensor = 34; 
int LED =18;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("Hello, ESP32!");
  Serial.begin(9600);
  Serial.println("Serial Working");
  pinMode(IRSensor, INPUT);
  pinMode(LED,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(10); // this speeds up the simulation
    int sensorStatus = digitalRead(IRSensor);
  if(sensorStatus == 1){
    digitalWrite(LED, HIGH);
    Serial.println("Object Detected!");
  }
  else{
    digitalWrite(LED, LOW);
    Serial.println("Object Ended!");
  }
}
Loading
ds18b20