public class UltrasonicHCSR04 extends GPIOComponent
The basic principle of work:
distance = (high level time X velocity of sound (340M/S) / 2
Note: for accuracy reasons, we need to directly use WiringPi functions instead of pi4j to control the pins, probably because pi4j is too slow to react (higher level).
|Constructor and Description|
Constructor for a variant of ultrasonic sensor HCSR04 using a signle Gpio pin for trigger and echo signals.
Constructor for an ultrasonic sensor HCSR04 using a specific Gpio trigger pin and a specific Gpio echo pin.
|Modifier and Type||Method and Description|
Get the calculated distance from the ultrasound sensor.
trigPin- the pin to use to trigger signals.
echoPin- the pin to use to detect echo signals.
public UltrasonicHCSR04(GPIOPin trigPin)
trigPin- the Gpio pin used for trigger and echo signals.