basic class for the use of the HC-SR04 ultrasound sensor
Diff: HC-SR04.h
- Revision:
- 0:b4a6f6bcab30
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HC-SR04.h Sun Oct 31 10:46:33 2021 +0000 @@ -0,0 +1,24 @@ +#pragma once +#include "mbed.h" + + +class HCSR04 { + DigitalIn echo_ ; + DigitalInOut trigger_; + + Timer t_; + int time_us_; + int distance_; + + +public: + + HCSR04(PinName echo, PinName trigger); + + void reading(); + void fastTimeReading(); + + int getTime(); + int getDistance(); + +}; \ No newline at end of file