Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed HC_SR04_Ultrasonic_Library
Revision 2:fb993dbcbbb0, committed 2021-09-26
- Comitter:
- michaelveloo
- Date:
- Sun Sep 26 11:10:10 2021 +0000
- Parent:
- 1:4a5586eb1765
- Commit message:
- 25 Sept Lab for Ultrasonic
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 4a5586eb1765 -r fb993dbcbbb0 main.cpp --- a/main.cpp Thu Dec 04 08:04:55 2014 +0000 +++ b/main.cpp Sun Sep 26 11:10:10 2021 +0000 @@ -3,11 +3,11 @@ void dist(int distance) { - //put code here to happen when the distance is changed + //Displays when the distance is changed printf("Distance changed to %dmm\r\n", distance); } -ultrasonic mu(D8, D9, .1, 1, &dist); //Set the trigger pin to D8 and the echo pin to D9 +ultrasonic mu(D8, D9, .1, 1, &dist); //Sets the trigger pin to p8 and the echo pin to p9 //have updates every .1 seconds and a timeout after 1 //second, and call dist when the distance changes @@ -16,7 +16,7 @@ mu.startUpdates();//start mesuring the distance while(1) { - //Do something else here + mu.checkDistance(); //call checkDistance() as much as possible, as this is where //the class checks if dist needs to be called. }