A simple class for an HC SR04 ultrasonic sensor, primarily for use with Arduinos.
Creates an HC_SR04 object (constructor).
- uint8_t trigPin: number of the pin connected to the trigger.
- uint8_t echoPin: number of the pin where the echo delay comes back on.
- unsigned long delay: the delay, in milliseconds, to wait for the echo. Default is 1000 ms.
Sets a new delay for listening for the echo.
- unsigned long delay: delay in milliseconds.
Returns distanced measured by the ultrasonic sensor in inches. If no echo was received in the delay time, then (unsigned long) -1 is returned.
Returns distanced measured by the ultrasonic sensor in centimeters. If no echo was received in the delay time, then (unsigned long) -1 is returned.