public class HCSR04UsingWait extends Object implements DistanceSensorInterface, Closeable
Constructor and Description |
---|
HCSR04UsingWait(int triggerGpioNum,
int echoGpioNum)
Initialise GPIO to echo and trigger pins
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Free device GPIOs
|
float |
getDistanceCm()
Send a pulse to HCSR04 and compute the echo to obtain distance
|
static void |
main(String[] args) |
public HCSR04UsingWait(int triggerGpioNum, int echoGpioNum) throws RuntimeIOException
triggerGpioNum
- GPIO connected to the HC-SR04 trigger pinechoGpioNum
- GPIO connected to the HC-SR04 echo pinRuntimeIOException
- if an I/O error occurspublic static void main(String[] args)
public float getDistanceCm() throws RuntimeIOException
getDistanceCm
in interface DistanceSensorInterface
RuntimeIOException
- if an I/O error occurspublic void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2016 mattjlewis. All rights reserved.