NMHU AAA Class HW4.1 base program For KL46Z.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
scohennm
Date:
Tue Sep 09 03:44:04 2014 +0000
Commit message:
NMHU AAA Class HW4.1 base program

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
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
diff -r 000000000000 -r ba4f1298c690 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Sep 09 03:44:04 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013
\ No newline at end of file