MatrixMiniR4 1.1.5
Matrix Mini R4 Arduino Library API Documentation
Loading...
Searching...
No Matches
MiniR4HC04< PIN1, PIN2 > Class Template Reference

Class for controlling the HC-SR04 ultrasonic sensor. More...

#include <MiniR4HC04.h>

Public Member Functions

 MiniR4HC04 ()
 
float getDistance (void)
 Measures the distance using the HC-SR04 sensor.
 

Detailed Description

template<uint8_t PIN1, uint8_t PIN2>
class MiniR4HC04< PIN1, PIN2 >

Class for controlling the HC-SR04 ultrasonic sensor.

This template class provides methods for using the HC-SR04 ultrasonic sensor to measure distance using specified trigger and echo pins.

Template Parameters
PIN1(Left) The pin number for the trigger signal.
PIN2(Right) The pin number for the echo signal.

Definition at line 21 of file MiniR4HC04.h.

Constructor & Destructor Documentation

◆ MiniR4HC04()

template<uint8_t PIN1, uint8_t PIN2>
MiniR4HC04< PIN1, PIN2 >::MiniR4HC04 ( )
inline

Definition at line 24 of file MiniR4HC04.h.

Member Function Documentation

◆ getDistance()

template<uint8_t PIN1, uint8_t PIN2>
float MiniR4HC04< PIN1, PIN2 >::getDistance ( void )
inline

Measures the distance using the HC-SR04 sensor.

Sends a trigger pulse and reads the echo response to calculate the distance in centimeters.

Returns
The distance in centimeters, or -1 if the sensor times out.

Definition at line 38 of file MiniR4HC04.h.


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