Eli Menchaca
/
lightsense_kl46z_basic
light sesnsor LEDs
Fork of lightsense_kl46z_basic by
Revision 10:380416fe6a88, committed 2016-09-19
- Comitter:
- menchacaeli
- Date:
- Mon Sep 19 02:34:00 2016 +0000
- Parent:
- 9:f619cdaa7a65
- Commit message:
- light sensor LEDs.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f619cdaa7a65 -r 380416fe6a88 main.cpp --- a/main.cpp Fri Sep 09 19:41:10 2016 +0000 +++ b/main.cpp Mon Sep 19 02:34:00 2016 +0000 @@ -6,12 +6,17 @@ #define DATATIME 400 // milliseconds #define LCDLEN 10 #define LIGHTSENSORPORT PTE22 - - +#define LEDON false +#define LEDOFF true +#define LRED "RED" +#define LGREEN "GREN" SLCD slcd; //define LCD display globally define Serial pc(USBTX, USBRX); Timer LEDTimer; +Timer LIGHTTimer; + +bool ledState = LEDON; void LCDMess(char *lMess){ slcd.Home(); @@ -19,7 +24,6 @@ slcd.printf(lMess); } - int main() { AnalogIn LightSensor(LIGHTSENSORPORT); float lightData; @@ -30,13 +34,18 @@ LEDTimer.reset(); pc.printf(PROGNAME); + PwmOut gled(LED_GREEN); + PwmOut rled(LED_RED); + 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); timeToChangeDF = DATATIME; + gled = 0.0; + rled = 0.0; LEDTimer.reset(); - } + } }// emd while }