Reads the value of POT0 on the TFC and maps it, then lights the battery LEDs accordingly, if button 0 is pressed, the LEDS flash.

Dependencies:   FRDM-TFC mbed

Files at this revision

API Documentation at this revision

Comitter:
NoamVH
Date:
Sat Feb 27 14:30:24 2016 +0000
Commit message:
Formatted & commented

Changed in this revision

FRDM-TFC.lib Show annotated file Show diff for this revision Revisions of this file
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 87b8a92b41b9 FRDM-TFC.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FRDM-TFC.lib	Sat Feb 27 14:30:24 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/ikrase/code/FRDM-TFC/#6cdfa332ec50
diff -r 000000000000 -r 87b8a92b41b9 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Feb 27 14:30:24 2016 +0000
@@ -0,0 +1,17 @@
+#include "mbed.h"
+#include "TFC.h"
+
+int main()
+{
+    TFC_Init(); //Initiate TFC
+    while(true) { //Loop start
+        float i = TFC_ReadPot(0); //Read potentiometers (A value between -1 to 1)
+        float v = (10*i + 10)/4; //Map value i to a range of 0 to 5
+        TFC_SetBatteryLED_Level(v);
+        if(TFC_PUSH_BUTTON_0_PRESSED) { //If button 0 is pressed, blink
+            wait(0.5);
+            TFC_SetBatteryLED_Level(0);
+            wait(0.5);
+        } //If end
+    } //Loop end
+} //Main end
\ No newline at end of file
diff -r 000000000000 -r 87b8a92b41b9 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Feb 27 14:30:24 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3
\ No newline at end of file