The use of the KL-46Z FRDM microcontroller to handle the I/O to detect water moisture and light exposure for a potted plant using a 555 Timer Chip and onboard visible light sensor. This project is incomplete as of 4/26/15

Dependencies:   SLCD mbed

Revision:
2:435f5545e2b6
Parent:
1:5b951fe1f430
--- a/main.cpp	Mon May 04 21:23:28 2015 +0000
+++ b/main.cpp	Mon May 04 21:37:27 2015 +0000
@@ -28,8 +28,12 @@
 #define MORELIGHT 4
 #define LESSLIGHT 5
 
-#define LIGHTMIN .100
-#define LIGHTMAX .900
+#define LIGHTMIN .100 //there is too much light
+#define LIGHTMAX .900 // there is not enough light
+
+#define WATERMAX 1500 //Do not water. There is Moisture
+#define WATERMIN 3000 //Water, there is no moisture
+
 #define ML "MORE LIGHT"
 #define LL "LESS LIGHT"
 #define MW "MORE WATER"
@@ -99,14 +103,27 @@
 void readTimerChip() {
     timerChip = oneShotOut.read();
    // pc.printf();
+   /****
+   #define  WATERMAX 1500 //Do not water. There is Moisture
+    #define WATERMIN 3000 //Water, there is no moisture
+ ***/
+    
+   if(timerChip >= WATERMAX) {
+        //Do not water move to check light
+        PgmState = CHECKLIGHT; 
+   }
+   else if(timerChip <= WATERMIN) {
+        //Tell pc to water then move to check light
+        pc.printf(MW);
+        PgmState = CHECKLIGHT; 
+   }
 }
 
 int main(){
-    setup();
+    
     pulseOut(OUTPULSELEN);
     //LCDMess(PROGNAME);
-    milliTimer.start();
-    milliTimer.reset();
+    setup();
     PgmState = TIMERSTATE; 
     int count = 0;
     
@@ -117,7 +134,7 @@
             //Go on to CHECKMOISTURE
             if(milliTimer.read_ms() >= MAXTIME) {
                 milliTimer.reset();
-                PgmState = CHECKLIGHT; 
+                PgmState = CHECKMOISTURE; 
             }
             break;
             case CHECKMOISTURE: