vehicle detection

Dependencies:   mbed HCSR04 DHT

Files at this revision

API Documentation at this revision

Comitter:
khp007
Date:
Tue Mar 20 03:32:56 2018 +0000
Child:
1:8711db3189d0
Commit message:
hcsr04 for pill dispenser, detects motion

Changed in this revision

DHT.lib Show annotated file Show diff for this revision Revisions of this file
HCSR04.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/DHT.lib	Tue Mar 20 03:32:56 2018 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/components/code/DHT/#6937e130feca
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HCSR04.lib	Tue Mar 20 03:32:56 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/aralshukaili/code/HCSR04/#0bda99bb39a4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 20 03:32:56 2018 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+#include "HCSR04.h"
+
+ Serial pc(USBTX,USBRX);     // Create a serial connection to pc through the mbed USB cable
+
+ void dist(int distance)
+{
+    //put code here to execute when the distance has changed
+    printf("Distance %d mm\r\n", distance);
+}
+
+HCSR04 sensor(D8,D9);
+DigitalOut Green(LED2);
+
+int main()
+{
+   wait_ms(4000);
+
+int echoVal = sensor.echo_duration();
+   Green = 1;
+   
+    while(1){
+    int a = sensor.echo_duration();
+    if (a - echoVal > 75 || echoVal - a > 75){
+        Green=0;
+        wait(.2);
+        Green=1;
+        wait(.2);
+    }
+    pc.printf("%d \n\r",a);
+    wait_ms(50);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Mar 20 03:32:56 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/aa5281ff4a02
\ No newline at end of file