For CW1

Dependencies:   mbed HC_SR04_Ultrasonic_Library

Files at this revision

API Documentation at this revision

Comitter:
michaelveloo
Date:
Sun Sep 26 10:48:03 2021 +0000
Commit message:
CW1

Changed in this revision

HC_SR04_Ultrasonic_Library.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HC_SR04_Ultrasonic_Library.lib	Sun Sep 26 10:48:03 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/ejteb/code/HC_SR04_Ultrasonic_Library/#e0f9c9fb4cf3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Sep 26 10:48:03 2021 +0000
@@ -0,0 +1,19 @@
+#include "mbed.h"
+#include "ultrasonic.h"
+void dist(int distance)
+{
+     //put code here to happen when the distance is changed
+     printf("Distance changed to %dmm\r\n", distance);
+}
+ultrasonic mu(p8, p9, .1, 1, &dist);     //Set 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
+int main()
+{
+     mu.startUpdates();//start mesuring the distance
+     while(1)
+     {
+         mu.checkDistance(); //call checkDistance() as much as possible, as this is where
+                             //the class checks if dist needs to be called. 
+     }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Sep 26 10:48:03 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file