C++ DevKit
C++ set of OOP library
Loading...
Searching...
No Matches
HCSR04 Class Reference

class for the ultrasonic ranging module HC-SR04 More...

#include <hc_sr04.h>

Collaboration diagram for HCSR04:
Collaboration graph

Public Member Functions

 HCSR04 (uint trig_pin, uint echo_pin)
 Construct a new hc sr04 object.
 
float get_distance ()
 request a measure from HCSR04
 

Private Member Functions

void trig ()
 send a trig signal to HCSR04
 

Private Attributes

uint trig_pin
 the GPIO pin that send trigger signal to the HC-SR04 module
 
uint echo_pin
 the GPIO pin where the HC-SR04 return echo signal
 

Detailed Description

class for the ultrasonic ranging module HC-SR04

Constructor & Destructor Documentation

◆ HCSR04()

HCSR04::HCSR04 ( uint trig_pin,
uint echo_pin )

Construct a new hc sr04 object.

Parameters
trig_pinthe pin attached to the triggering signal
echo_pinthe pin used to measure round-trip time of ultrasonic pulses

Member Function Documentation

◆ get_distance()

float HCSR04::get_distance ( )

request a measure from HCSR04

Returns
the measured distance in float[cm]. Max = 400cm. If no response, return = -1.
Here is the call graph for this function:

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