Dhiraj Matlani / HCSR04

Files at this revision

API Documentation at this revision

Comitter:
VPKD1669
Date:
Fri Dec 06 21:52:13 2019 +0000
Parent:
8:25138f7b9309
Commit message:
IT WORKS EFFECTIVELY WITH ULTRASONIC SENSOR

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Jan 13 14:48:25 2017 +0000
+++ b/main.cpp	Fri Dec 06 21:52:13 2019 +0000
@@ -3,16 +3,31 @@
 
  
 DigitalOut myled(LED1);
-HCSR04  usensor(D8,D9);
+Serial pc(USBTX,USBRX);
+HCSR04  usensor(D8,D12);
 unsigned int dist;
+DigitalOut GREEN(D13); 
+DigitalOut BLUE(LED3);  
+Timer dt;
+
 int main()
 {
- 
+    BLUE=1;
+    pc.baud(9600);
+    dt.start(); 
     while(1) {
         usensor.start();
         wait_ms(500); 
         dist=usensor.get_dist_cm();
-        printf("\n\r cm:%ld",dist );
+        printf("\n\r cm:%ld",dist);
+        if (dist>1 and dist<=20)
+        {
+         GREEN = !GREEN;
+        }
+        else
+        {
+            BLUE=0;
+        }
  
     }
 }
\ No newline at end of file
--- a/mbed.bld	Fri Jan 13 14:48:25 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/99b5ccf27215
\ No newline at end of file