Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed mbed-http TextLCD ESP8266 ULN2003_StepperDriver
Diff: main.cpp
- Revision:
- 9:607ee6e92552
- Parent:
- 8:25138f7b9309
- Child:
- 10:e4b6bc6d9b07
--- 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