NMHU AAA Class HW4.1 base program For KL46Z.

Dependencies:   mbed

Committer:
scohennm
Date:
Tue Sep 09 03:44:04 2014 +0000
Revision:
0:ba4f1298c690
NMHU AAA Class HW4.1 base program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
scohennm 0:ba4f1298c690 1 #include "mbed.h"
scohennm 0:ba4f1298c690 2 #define PROGNAME "Light_Sense_v1\n\r"
scohennm 0:ba4f1298c690 3 #define DATATIME 0.5
scohennm 0:ba4f1298c690 4
scohennm 0:ba4f1298c690 5 #define PRINTDEBUG
scohennm 0:ba4f1298c690 6
scohennm 0:ba4f1298c690 7 AnalogIn LightSensor(PTE22); // define light sensor
scohennm 0:ba4f1298c690 8 PwmOut redLed(LED_RED);
scohennm 0:ba4f1298c690 9
scohennm 0:ba4f1298c690 10 Serial pc(USBTX, USBRX);
scohennm 0:ba4f1298c690 11
scohennm 0:ba4f1298c690 12 int main()
scohennm 0:ba4f1298c690 13 {
scohennm 0:ba4f1298c690 14 float lightVal;
scohennm 0:ba4f1298c690 15 unsigned short lightWord;
scohennm 0:ba4f1298c690 16
scohennm 0:ba4f1298c690 17 pc.printf(PROGNAME);
scohennm 0:ba4f1298c690 18
scohennm 0:ba4f1298c690 19 while (true) {
scohennm 0:ba4f1298c690 20 lightVal = LightSensor.read();
scohennm 0:ba4f1298c690 21 lightWord = LightSensor.read_u16();
scohennm 0:ba4f1298c690 22 redLed = lightVal;
scohennm 0:ba4f1298c690 23 #ifdef PRINTDEBUG
scohennm 0:ba4f1298c690 24 pc.printf("LS => %1.3f %5d \r\n", lightVal, lightWord);
scohennm 0:ba4f1298c690 25 #endif
scohennm 0:ba4f1298c690 26 wait(DATATIME);
scohennm 0:ba4f1298c690 27 }
scohennm 0:ba4f1298c690 28 }