KBrat-SSD541-HW-5_2

Dependencies:   SLCD mbed

Fork of lightsense_kl46z_basic by Stanley Cohen

Revision:
10:8ad79c335cfa
Parent:
9:f619cdaa7a65
diff -r f619cdaa7a65 -r 8ad79c335cfa main.cpp
--- a/main.cpp	Fri Sep 09 19:41:10 2016 +0000
+++ b/main.cpp	Mon Sep 19 06:21:08 2016 +0000
@@ -2,7 +2,7 @@
 #include "SLCD.h"
 
 
-#define PROGNAME "lightsense_kl46z_basic v1\n\r"
+#define PROGNAME "KBrat-SSD541-HW-5_2_Part1\n\r"
 #define DATATIME 400 // milliseconds
 #define LCDLEN 10
 #define LIGHTSENSORPORT PTE22
@@ -24,6 +24,8 @@
     AnalogIn LightSensor(LIGHTSENSORPORT);
     float lightData; 
     char lcdData[LCDLEN];
+    PwmOut gled(LED_GREEN);
+    PwmOut rled(LED_RED);
    
     int timeToChangeDF = DATATIME;
     LEDTimer.start();
@@ -32,11 +34,15 @@
     
     while(true) {    
         if (LEDTimer.read_ms() > timeToChangeDF){ // check for timer time out transtion
-            lightData = (1.0 - LightSensor.read()); // show as increasiing with increasing intensity  
-            sprintf(lcdData,"%4.3f",lightData);       
-            LCDMess(lcdData);  
+            lightData = (1.0 - LightSensor.read()); // show as increasing with increasing intensity  
+            sprintf(lcdData,"%4.3f",lightData);
+            LCDMess(lcdData);
+            gled = 1.0 - lightData;   //green light changes intensity as light data changes
+            rled = 1.0 - lightData;   //red light changes intensity as light data changes
             timeToChangeDF = DATATIME;
             LEDTimer.reset();
         }        
-    }// emd while
+    }// end while
 }
+
+