Fully integrated working system

Dependencies:   Speaker mbed mbed-rtos 4DGL-uLCD-SE hcsr04

Committer:
tadhgjones
Date:
Wed Dec 16 10:38:23 2020 +0000
Revision:
8:f3ab61374cd0
Child:
9:d1b00a2a8e25
EE3023

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tadhgjones 8:f3ab61374cd0 1 #include "mbed.h"
tadhgjones 8:f3ab61374cd0 2 #include "hcsr04.h"
tadhgjones 8:f3ab61374cd0 3 #include "Speaker.h"
tadhgjones 8:f3ab61374cd0 4
tadhgjones 8:f3ab61374cd0 5 HCSR04 usensor(p25,p6);
tadhgjones 8:f3ab61374cd0 6 Serial pc(USBTX, USBRX);
tadhgjones 8:f3ab61374cd0 7 Speaker mySpeaker(p18);
tadhgjones 8:f3ab61374cd0 8
tadhgjones 8:f3ab61374cd0 9 unsigned int dist;
tadhgjones 8:f3ab61374cd0 10 int main()
tadhgjones 8:f3ab61374cd0 11 {
tadhgjones 8:f3ab61374cd0 12
tadhgjones 8:f3ab61374cd0 13 while(1) {
tadhgjones 8:f3ab61374cd0 14 usensor.start();
tadhgjones 8:f3ab61374cd0 15 wait_ms(50);
tadhgjones 8:f3ab61374cd0 16 dist=usensor.get_dist_cm();
tadhgjones 8:f3ab61374cd0 17
tadhgjones 8:f3ab61374cd0 18 mySpeaker.PlayNote(329.63, 0.5, 1.0);
tadhgjones 8:f3ab61374cd0 19
tadhgjones 8:f3ab61374cd0 20 pc.printf("cm:%ld\n",dist );
tadhgjones 8:f3ab61374cd0 21
tadhgjones 8:f3ab61374cd0 22 }
tadhgjones 8:f3ab61374cd0 23 }