NMHU AAA Class HW4.1 base program For KL46Z.

Dependencies:   mbed

Revision:
0:ba4f1298c690
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