HW2 text entry device for idd 2015. Allows user to type with a knob and a push button.
Dependencies: mbed
Revision 0:0028c9f455d1, committed 2015-09-14
- Comitter:
- franklu
- Date:
- Mon Sep 14 06:29:34 2015 +0000
- Commit message:
- added main.cpp
Changed in this revision
--- /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
--- /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
--- /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