upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Public Member Functions | List of all members

API for the HC-SR04 Ultrasonic Sensor. More...

Detailed Description

This module defines the HC-SR04 interface for libhcsr04

public static void main(String[] args) throws InterruptedException {
upm_hcsr04.HCSR04 sonar = new upm_hcsr04.HCSR04((short) 5, (short) 6);
Thread.sleep(1000);
while (true) {
System.out.println("Get distance");
double distance = sonar.getDistance(upm_hcsr04.javaupm_hcsr04Constants.CM);
System.out.println("Distance: " + distance);
Thread.sleep(5000);
}
}
}

Public Member Functions

synchronized void delete ()
 
 HCSR04 (short triggerPin, short echoPin)
 
double getDistance (int sys)
 
void setM_doWork (short value)
 
short getM_doWork ()
 
String name ()
 

Constructor & Destructor Documentation

HCSR04 ( short  triggerPin,
short  echoPin 
)

Instantiates an HCSR04 object

Parameters
triggerPinPin to trigger the sensor for distance
echoPinPulse response to triggering
fptrFunction pointer to handle rising-edge and falling-edge interrupts

Member Function Documentation

double getDistance ( int  sys)

Gets the distance from the sensor

short getM_doWork ( )

Flag to control blocking function while waiting for a falling-edge interrupt

String name ( )

Returns the name of the sensor


The documentation for this class was generated from the following file: