![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
semi integrated
Dependencies: Speaker mbed 4DGL-uLCD-SE hcsr04
Diff: main.cpp
- Revision:
- 8:f3ab61374cd0
- Child:
- 9:d1b00a2a8e25
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Dec 16 10:38:23 2020 +0000 @@ -0,0 +1,23 @@ +#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 ); + + } +} \ No newline at end of file