sdf

Dependencies:   mbed C12832 Servo RangeFinder Pulse

Files at this revision

API Documentation at this revision

Comitter:
asimelfadil
Date:
Tue Mar 01 13:49:18 2022 +0000
Parent:
0:4db5f0f5faa0
Commit message:
Group 66 Course Work 2

Changed in this revision

C12832.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
diff -r 4db5f0f5faa0 -r 47dc87d326ed C12832.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832.lib	Tue Mar 01 13:49:18 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/askksa12543/code/C12832/#990d5eec2ef6
diff -r 4db5f0f5faa0 -r 47dc87d326ed main.cpp
--- a/main.cpp	Wed Feb 23 10:19:24 2022 +0000
+++ b/main.cpp	Tue Mar 01 13:49:18 2022 +0000
@@ -3,6 +3,7 @@
 #include "RangeFinder.h"
 #include <Motor_relay.h>
 #include "Servo.h"
+#include <C12832.h>
 
 int dry = 0.61;
 int wet = 0.37;
@@ -13,7 +14,7 @@
 MOTOR_RELAY motor_relay2(p21);
 Servo valve1(p23);
 Servo valve2(p24);
-
+C12832 mylcd(p5,p7,p6,p8,p11);
 #define on  1
 #define off 0
 int main (void)
@@ -28,6 +29,9 @@
         moisturevalue = grove.read();
         moisturepercentage=(((moisturevalue- 0.37)/(0.61-0.37))*100);
         debug("Moisture reading is %2.2f percent dry\n\r",moisturepercentage);
+        mylcd.locate(0,0);
+        mylcd.printf("Moist: %.2f",moisturepercentage);
+
         wait(1.0f);
 
         d = rf.read_m();
@@ -39,28 +43,47 @@
             printf("No object within detection range.\n");
         } else  {
             printf("Distance = %f m.\n", d);
+            mylcd.locate(0,10);
+            mylcd.printf("Distance = %f m.\n", d);
         }
         wait(0.5);
         led = !led;
-        
-        
-        if(moisturepercentage>80){
+
+
+        if(moisturepercentage>80) {
+            mylcd.locate(0,10);
+            mylcd.printf("outletvalve:open pump:on");
             motor_relay1.SetMotor(1);
             valve1.position(0);
-            }
-        if(moisturepercentage<20){
+        }
+        if(moisturepercentage<20) {
+            mylcd.locate(0,10);
+            mylcd.printf("outletvalve:close pump:off");
             motor_relay1.SetMotor(0);
-              valve1.position(90);
-            }  
-       
+            valve1.position(90);
+        }
+        if(20<moisturepercentage<80) {
+            mylcd.locate(0,10);
+            mylcd.printf("Moisture:ok pump:off");
+            motor_relay1.SetMotor(0);
+        }
         if (d>0.07 ) {
+            mylcd.locate(0,20);
+            mylcd.printf("inletvalve:open pump:on");
             motor_relay2.SetMotor(1);
             valve2.position(90);
         }
         if(d<0.02) {
+            mylcd.locate(0,20);
+            mylcd.printf("inletvalve:closed pump:off");
             motor_relay2.SetMotor(0);
             valve2.position(0);
         }
+        if (0.02<d<0.07) {
+            mylcd.locate(0,20);
+            mylcd.printf("water level:ok pump:off");
+            motor_relay2.SetMotor(0);
+        }
     }
     return 0;
 }