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_basic by
Revision 11:75596fecb8d5, committed 2016-09-19
- Comitter:
- annalou
- Date:
- Mon Sep 19 04:07:39 2016 +0000
- Parent:
- 10:4fa8bf6e3ade
- Commit message:
- AMartSSD341_HW5.2Pt2
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Sep 19 02:37:43 2016 +0000
+++ b/main.cpp Mon Sep 19 04:07:39 2016 +0000
@@ -6,6 +6,9 @@
#define DATATIME 400 // milliseconds
#define LCDLEN 10
#define LIGHTSENSORPORT PTE22
+#define LBUT PTC12 // port addresses for buttons
+#define RBUT PTC3
+
@@ -13,6 +16,8 @@
Serial pc(USBTX, USBRX);
Timer LEDTimer;
+DigitalIn buttons[2] = {RBUT, LBUT};
+
void LCDMess(char *lMess)
{
slcd.Home();
@@ -28,6 +33,8 @@
char lcdData[LCDLEN];
PwmOut gled(LED_GREEN);
PwmOut rled(LED_RED);
+ unsigned short lightWord;
+ bool lButON = false;
int timeToChangeDF = DATATIME;
LEDTimer.start();
@@ -40,10 +47,24 @@
sprintf(lcdData,"%4.3f",lightData);
LCDMess(lcdData);
timeToChangeDF = DATATIME;
- pc.printf(lcdData);
+ //pc.printf(lcdData);
rled = lightData;
gled = lightData;
+
+ //using if to switch between the RAW and Float output
+ if(lButON == true)
+ {
+ lightWord = LightSensor.read_u16();
+ pc.printf("LS => %10d \r\n", lightWord);
+ lButON = false;
+ }
+ else
+ {
+ lightData = (1.0 - LightSensor.read());
+ pc.printf("ls => %1.3f \r\n", lightData);
+ lButON = true;
+ }
LEDTimer.reset();
}
- }// emd while
+ }// end while
}
