Library for the ultrasonic rangefinder HC-SR04.
Add the following lines of code to your platformio.ini file:
lib_deps =
https://github.com/WPIRoboticsEngineering/Rangefinder
You are done.
The main classes and functions provided by the library are listed below:
- Rangefinder(uint8_t echo, uint8_t trig);
- void init(void);
- uint8_t checkPingTimer(void);
- uint16_t checkEcho(void);
- float getDistance(void);
- void ISR_echo(void);
The datasheet of the HC-SR04 rangefinder can be found here.