Kenneth Lujan
/
light_sense_46_
KLUJA-SSD341-Hw-5.2
Fork of light_sense_46 by
Diff: main.cpp
- Revision:
- 0:ba4f1298c690
- Child:
- 1:9e9a864e45ca
diff -r 000000000000 -r ba4f1298c690 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Sep 09 03:44:04 2014 +0000 @@ -0,0 +1,28 @@ +#include "mbed.h" +#define PROGNAME "Light_Sense_v1\n\r" +#define DATATIME 0.5 + +#define PRINTDEBUG + +AnalogIn LightSensor(PTE22); // define light sensor +PwmOut redLed(LED_RED); + +Serial pc(USBTX, USBRX); + +int main() +{ + float lightVal; + unsigned short lightWord; + + pc.printf(PROGNAME); + + while (true) { + lightVal = LightSensor.read(); + lightWord = LightSensor.read_u16(); + redLed = lightVal; +#ifdef PRINTDEBUG + pc.printf("LS => %1.3f %5d \r\n", lightVal, lightWord); +#endif + wait(DATATIME); + } +} \ No newline at end of file