![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Measure Distance
main.cpp
- Committer:
- tadhgjones
- Date:
- 2020-12-16
- Revision:
- 8:f3ab61374cd0
File content as of revision 8:f3ab61374cd0:
#include "mbed.h" #include "hcsr04.h" #include "Speaker.h" HCSR04 usensor(p25,p6); Serial pc(USBTX, USBRX); Speaker mySpeaker(p18); unsigned int dist; int main() { while(1) { usensor.start(); wait_ms(50); dist=usensor.get_dist_cm(); mySpeaker.PlayNote(329.63, 0.5, 1.0); pc.printf("cm:%ld\n",dist ); } }