Sonar demo with timer interrupts
Dependencies: HC_SR04_Ultrasonic_Library mbed
Fork of Nucleo_UltrasonicHelloWorld by
Revision 2:3566c2d1e86b, committed 2016-09-13
- Comitter:
- 4180_1
- Date:
- Tue Sep 13 18:16:42 2016 +0000
- Parent:
- 1:4a5586eb1765
- Commit message:
- ver 1.0
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 4a5586eb1765 -r 3566c2d1e86b main.cpp --- a/main.cpp Thu Dec 04 08:04:55 2014 +0000 +++ b/main.cpp Tue Sep 13 18:16:42 2016 +0000 @@ -3,17 +3,17 @@ void dist(int distance) { - //put code here to happen when the distance is changed - printf("Distance changed to %dmm\r\n", distance); + //put code here to execute when the distance has changed + printf("Distance %d mm\r\n", distance); } -ultrasonic mu(D8, D9, .1, 1, &dist); //Set the trigger pin to D8 and the echo pin to D9 +ultrasonic mu(p6, p7, .1, 1, &dist); //Set the trigger pin to D8 and the echo pin to D9 //have updates every .1 seconds and a timeout after 1 //second, and call dist when the distance changes int main() { - mu.startUpdates();//start mesuring the distance + mu.startUpdates();//start measuring the distance while(1) { //Do something else here