Type the only important words you will ever need with this simple keyboard. Input key presses by touching the capacitive slider and watch as the words show up on your screen. Requires the FRDM to be connected to a computer using the USB port.

Dependencies:   USBDevice mbed tsi_sensor

Revision:
0:fb74ddc7b758
Child:
1:d8b92f4c7e03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Aug 22 02:12:30 2014 +0000
@@ -0,0 +1,59 @@
+/* Created by Mark Oehlberg 8/21/14
+
+Automatic keyboard app
+
+You are viewing the code for the future of keyboards.  You might as well
+smash your current keyboard, because once you use your KL25Z as 
+
+*/
+
+#include "mbed.h"
+#include "tsi_sensor.h"
+#include "USBKeyboard.h"
+
+/* These defines will be replaced by PinNames soon */
+#if defined (TARGET_KL25Z) || defined (TARGET_KL46Z)
+  #define ELEC0 9
+  #define ELEC1 10
+#elif defined (TARGET_KL05Z)
+  #define ELEC0 9
+  #define ELEC1 8
+#else
+  #error TARGET NOT DEFINED
+#endif
+
+Serial pc(USBTX, USBRX);
+USBKeyboard keyboard;
+
+bool justpressed = false;
+float lastpressed = 0.0;
+
+int main(void) {
+    pc.baud(115200);//I apparently have to do this in the main loop
+    PwmOut led(LED2);//also called LED_GREEN
+    TSIAnalogSlider tsi(ELEC0, ELEC1, 40);
+    pc.printf("\nSerial port activated!\n\r");
+    float i=0.0;
+    while (true) {
+        i=1.0 - tsi.readPercentage();
+        led = i;
+        if (justpressed && (abs(lastpressed-i)>0.1)){
+            justpressed=false;
+        }
+        if ( 0.5 < i && i < 1.0 && not justpressed ){          
+            keyboard.printf("Pirates!\r\n");
+            lastpressed = i;
+            justpressed = true;
+            pc.printf(" Pirates - Trigger number=%f\n\r",i);
+        }else if (0.0 < i && i <= 0.5 && not justpressed ){          
+            keyboard.printf("ROBOTS!\r\n");
+            lastpressed = i;
+            justpressed = true;
+            pc.printf(" ROBOTS!- Trigger number=%f\n\r",i);
+        }
+
+        wait(0.1);//this is to not overload the PWM output (writing multiple times to the LED)
+        //pc.printf("Reading:%f\tlastpressed:%f Justpressed:%d\n\r", i,lastpressed, justpressed);//debug code
+
+    }
+}