Original Code Repo: https://os.mbed.com/users/priyank12p/code/Electronically-Connected-Intelligent-She/ Modified for Fall 2021 students.

Dependencies:   mbed mbed-http ESP8266

Revision:
9:607ee6e92552
Parent:
8:25138f7b9309
Child:
10:e4b6bc6d9b07
diff -r 25138f7b9309 -r 607ee6e92552 main.cpp
--- a/main.cpp	Fri Jan 13 14:48:25 2017 +0000
+++ b/main.cpp	Wed Nov 27 20:53:24 2019 +0000
@@ -1,18 +1,40 @@
+/** 
+Group 1: Electronically Controlled Intelligent Systems
+Team Members: Priyank Kalgaonkar, Sahil Kumar, Linknath Balasubramanian
+ECE53301 - Final Project - Fall 2019
+**/
 #include "mbed.h"
 #include "hcsr04.h"
+ 
+DigitalOut RLed(LED1);                  //Onboard Red LED = Warning
+DigitalOut GLed(LED2);                  //Onboard Green LED = All OK
+DigitalOut BLed(LED3);                  //Onboard Blue LED = Wifi Tx
+HCSR04 usensor1(D8,D9);                 //ECHO Pin=D9, TRIG Pin=D8
 
- 
-DigitalOut myled(LED1);
-HCSR04  usensor(D8,D9);
-unsigned int dist;
+float distance;                  //distance=int for faster program exec.
+float dist_remaining;
+float dist_percent;
+
 int main()
 {
- 
+    int a = 30;
     while(1) {
-        usensor.start();
-        wait_ms(500); 
-        dist=usensor.get_dist_cm();
-        printf("\n\r cm:%ld",dist );
- 
+        usensor1.start();
+        wait_ms(1000); 
+        distance = usensor1.get_dist_cm();
+        dist_remaining = a-distance;
+        dist_percent = (dist_remaining/30)*100;
+        
+        if (distance<30) {
+            RLed = 1;
+            BLed = 1;
+            GLed = 0;
+            printf("\rPercent remaining: %f\r", dist_percent);
+        } else {
+            GLed = 1;
+            BLed = 1;
+            RLed = 0;
+            printf("\rShelf Empty. Replenish Stock!\r");
+        }
     }
 }
\ No newline at end of file