//ESP32 mit HC-SR04 und TFT
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define PIN_TRIG 33
#define PIN_ECHO 34
void setup(){
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(PIN_TRIG, OUTPUT);
pinMode(PIN_ECHO, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(PIN_TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(PIN_TRIG, LOW);
//Read the result
int duration = pulseIn(PIN_ECHO, HIGH);
Serial.print("Distance in CM: ");
Serial.println(duration / 58);
delay(1000); // this speeds up the simulation
}