![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
First Draft, serial print change based on distance
Diff: Ultrasonic/ultrasonic.h
- Revision:
- 12:b562893a1445
- Parent:
- 11:5a895d966a3e
--- a/Ultrasonic/ultrasonic.h Thu Feb 03 17:43:32 2022 +0000 +++ b/Ultrasonic/ultrasonic.h Thu Feb 03 18:36:34 2022 +0000 @@ -3,6 +3,43 @@ #include "mbed.h" +/** Ultrasonic Class +@brief Acknowledgements to EJ Teb +@brief Library for interfacing with ultrasonic sensor + + +Example: + +@code + +#include "mbed.h" +#include "ultrasonic.h" + + void dist(int distance) +{ + printf("Distance changed to %dmm\r\n", distance); + + } + + +ultrasonic mu(PTD0, PTC12, .1, 1, &dist); //Set the trigger pin to PTD0 and the echo pin to PTC12 + //have updates every .1 seconds and a timeout after 1 + //second, and call dist when the distance changes + +int main() +{ + mu.startUpdates();//start mesuring the distance + while(1) + { + //Do something else here + mu.checkDistance(); //call checkDistance() as much as possible, as this is where + //the class checks if dist needs to be called. + } +} + + +* @endcode +*/ class ultrasonic { public: