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
main.cpp
- Committer:
- scohennm
- Date:
- 2016-09-09
- Revision:
- 9:f619cdaa7a65
- Parent:
- 8:3b19ecdc4261
- Child:
- 10:4fa8bf6e3ade
File content as of revision 9:f619cdaa7a65:
#include "mbed.h"
#include "SLCD.h"
#define PROGNAME "lightsense_kl46z_basic v1\n\r"
#define DATATIME 400 // milliseconds
#define LCDLEN 10
#define LIGHTSENSORPORT PTE22
SLCD slcd; //define LCD display globally define
Serial pc(USBTX, USBRX);
Timer LEDTimer;
void LCDMess(char *lMess){
slcd.Home();
slcd.clear();
slcd.printf(lMess);
}
int main() {
AnalogIn LightSensor(LIGHTSENSORPORT);
float lightData;
char lcdData[LCDLEN];
int timeToChangeDF = DATATIME;
LEDTimer.start();
LEDTimer.reset();
pc.printf(PROGNAME);
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;
LEDTimer.reset();
}
}// emd while
}
