Ultrasonic sensor Hello World Code

Dependencies:   HC_SR04_Ultrasonic_Library mbed

Dependents:   Bluetooth-Controlled-Semi-automatic-Car

Fork of LPC1768_HCSR04_HelloWorld by jim hamblen

Files at this revision

API Documentation at this revision

Comitter:
Rohit99
Date:
Sat May 19 10:17:21 2018 +0000
Parent:
2:3566c2d1e86b
Commit message:
Imported HC-SR04 ibrary

Changed in this revision

main.cpp Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Sep 13 18:16:42 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-#include "mbed.h"
-#include "ultrasonic.h"
-
- void dist(int distance)
-{
-    //put code here to execute when the distance has changed
-    printf("Distance %d mm\r\n", distance);
-}
-
-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 measuring 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.
-    }
-}