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

Files at this revision

API Documentation at this revision

Comitter:
oehlberg
Date:
Fri Aug 22 02:12:30 2014 +0000
Child:
1:d8b92f4c7e03
Commit message:
First release of the pirates and robots

Changed in this revision

USBDevice.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
tsi_sensor.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Fri Aug 22 02:12:30 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mjr/code/USBDevice/#81f57ea86f8f
--- /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
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Aug 22 02:12:30 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsi_sensor.lib	Fri Aug 22 02:12:30 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Kojto/code/tsi_sensor/#20ffa9b18488