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

Dependencies:   mbed

Revision:
0:0028c9f455d1
--- /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