HW2 text entry device for idd 2015. Allows user to type with a knob and a push button.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
franklu
Date:
Mon Sep 14 06:29:34 2015 +0000
Commit message:
added main.cpp

Changed in this revision

PinDetect.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 0028c9f455d1 PinDetect.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PinDetect.lib	Mon Sep 14 06:29:34 2015 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/franklu/code/idd_hw2_franklu_pushntwist/#9fd31ff35d6c
diff -r 000000000000 -r 0028c9f455d1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Sep 14 06:29:34 2015 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+#include "PinDetect.h"
+// Initialize a pins to perform analog input and digital output fucntions
+AnalogIn   ain(A0);
+DigitalOut dout(D3);
+PinDetect  pin(D2);
+char letter;
+char *lower_arr = " zyxwvutsrqponmlkjihgfedcba";
+char *upper_arr = " ZYXWVUTSRQPONMLKJIHGFEDCBA";
+char *arr = lower_arr;
+void enter(void)
+{
+    printf("%c", letter);
+}
+
+void capslock_on(void) {
+    dout = !dout;
+}
+
+int main(void)
+{    
+    dout = 0;
+    pin.setSampleFrequency();
+    pin.attach_asserted(&enter);
+    pin.attach_deasserted_held(&capslock_on);
+    printf("\r\n Input here: \r\n ");    
+    while (1) {
+        if (dout){
+            arr = upper_arr;
+        } else {
+            arr = lower_arr;
+        }
+        int input = (int)(ain.read()* 100.0f / 3.705f);
+        letter = arr[input];
+        printf("%c", letter);
+        printf("\b");
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 0028c9f455d1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Sep 14 06:29:34 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ba1f97679dad
\ No newline at end of file