semi integrated
Dependencies: Speaker mbed 4DGL-uLCD-SE hcsr04
main.cpp@8:f3ab61374cd0, 2020-12-16 (annotated)
- Committer:
- tadhgjones
- Date:
- Wed Dec 16 10:38:23 2020 +0000
- Revision:
- 8:f3ab61374cd0
- Child:
- 9:d1b00a2a8e25
EE3023
Who changed what in which revision?
User | Revision | Line number | New 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 | } |