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.
Fork of lightsense_kl46z_PWM_simple by
Revision 9:96ddab3435d2, committed 2017-02-06
- Comitter:
- scohennm
- Date:
- Mon Feb 06 18:59:14 2017 +0000
- Parent:
- 8:ea818c9220fc
- Commit message:
- measure luc
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Jan 25 16:10:38 2016 +0000
+++ b/main.cpp Mon Feb 06 18:59:14 2017 +0000
@@ -6,6 +6,9 @@
#define DATATIME 400 // milliseconds
#define LCDLEN 10
#define LIGHTSENSORPORT PTE22
+#define LUXSCALING 1650 // full scale lux 500 lux/volt
+#define LIMTMESSAGE "OVER"
+#define FULLSCALE 1000.0
@@ -24,6 +27,7 @@
PwmOut redColor(LED_RED);
AnalogIn LightSensor(LIGHTSENSORPORT);
float lightData;
+ float luxData;
char lcdData[LCDLEN];
int timeToChangeDF = DATATIME;
@@ -35,12 +39,18 @@
while(true) {
if (LEDTimer.read_ms() > timeToChangeDF){ // check for timer time out transtion
+ // start out assuming over 1000 lux
+ sprintf(lcdData,"%s",LIMTMESSAGE);
lightData = (1.0 - LightSensor.read()); // show as increasiing with increasing intensity
+ luxData = lightData * LUXSCALING;
+
greenColor.write(1.0- lightData);
redColor.write(1.0-lightData);
- sprintf(lcdData,"%4.3f",lightData);
+ if( luxData < FULLSCALE){
+ sprintf(lcdData,"%4.0f",luxData);
+ }
LCDMess(lcdData);
- pc.printf("%4.3f\r\n",lightData);
+ pc.printf("%4.3f" "%4.0f\r\n",lightData,luxData);
timeToChangeDF = DATATIME;
LEDTimer.reset();
}
