HEPTA-Sat Training 2020
/
Lab7-sample_ultrasonic-sensor
for textbook v4.4
HC-SR04 program
Diff: main.cpp
- Revision:
- 0:5f87b3c8e32a
diff -r 000000000000 -r 5f87b3c8e32a main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Nov 06 18:12:17 2019 +0000 @@ -0,0 +1,14 @@ +#include "mbed.h" +#include "hcsr04.h" +Serial pc(USBTX, USBRX); +HCSR04 usensor(p21,p12); +int dist; +int main() +{ + while(1) { + usensor.start(); + dist=usensor.get_dist_cm(); + pc.printf("distance = %d [cm]\r\n",dist); + wait(1); + } +} \ No newline at end of file