const int triggerPin = 4p; // GPIO pin for the ultrasonic sensor trigger const int echoPin = 3; // GPIO pin for the ultrasonic sensor echo void setup() { Serial.begin(9600); pinMode(triggerPin, OUTPUT); pinMode(echoPin, INPUT); } void loop() { // Trigger ultrasonic sensor by sending a pulse digitalWrite(triggerPin, LOW); delayMicroseconds(2); digitalWrite(triggerPin, HIGH); delayMicroseconds(10); digitalWrite(triggerPin, LOW); // Measure the duration of the echo pulse unsigned long duration = pulseIn(echoPin, HIGH); // Calculate the distance in centimeters float distance = (duration * 0.0343) / 2; // Print the distance to the Serial Monitor Serial.print("Distance: "); Serial.print(distance); Serial.println(" cm"); delay(1000); // Wait for a short duration before the next measurement }