Hi, I have used Yerg2k's cool switchboard code and plans to get me a step closer to making a hand-held keyboard similar to a Microwriter or a Cykey.
I bought some cheap pushbuttons from Maplins and wired them with some CAT5 cable. I then embedded the keys into some Polymorph plastic (melts in hot water) and hid all the wires.
Once the "handle" had dried, I patched it into the Arduino and ran Yerg2ks code.
Too my delight, I now have a handheld "keyboard" that sends pairs to the serial port - all I need to do now is to map out combinations of keys to letters of the alphabet. However, I am not clever enough to do this!!
The code should listen for a combination of keypresses and send the appropriate letter to the serial port, for example, pressing buttons 1 &5 would send an "A", buttons 2 & 4 a "B" or whatever. Can anyone help me with the code - should this lookup code take place in the Arduino, or do I have to use another app written in VB or something? My preference is to use the Arduino to process all of the code and then use Serial Keys on XP to pass the characters from the Serial port to Word or whatever.
The code should listen for a combination of keypresses and send the appropriate letter to the serial port, for example, pressing buttons 1 &5 would send an "A", buttons 2 & 4 a "B" or whatever. Can anyone help me with the code - should this lookup code take place in the Arduino, or do I have to use another app written in VB or something? My preference is to use the Arduino to process all of the code and then use Serial Keys on XP to pass the characters from the Serial port to Word or whatever.
You possibly actually have another option available to you...
While it's probably more complex, it may be possible to have your device function as an actual PS/2 keyboard or (with--currently--much more complexity) a USB HID keyboard.
i'm doing something very similar for an instrument i built, and would like suggest that you add at least a sixth button to your interface.
with 5 buttons you only get 32 combinations (including "no-button pressed"). Though this enough for 26 lowcase letters and some selected punctuation, i bet you will soon miss numbers from 0-9... i guess that you're building this thing with a one-hand use in mind, but still this is something to consider.
the number of combinations double with each additional button. In fact your input is a binary number going from 00000(zero) to 11111 (31).
Here's some code (testest, but ripped ou off context) to read 4 buttons as a binary number (a nibble).
another thing to keep in mind is that you don't know when to read the input, it's theoretically impossible for the user to press all buttons at exactly the same time. that's why i thought your thumb button would act as trigger-button, but this would only give you 16 combinations, only half of the alphabet.
so if it wasn't for a one-hand device i would suggest using 8 input buttons + 1 trigger. With 8 buttons you don't even need to reinvent the encoding. The user could just enter ASCii values
I have considered more buttons in fact there will be six in total - the original http://en.wikipedia.org/wiki/Microwriterhad 6 buttons as one was for "mode" to cycle between caps, punctuation, numbers etc. But for now there are five as I want to keep things simple to start.
You should be able to check for multiple presses because the rule will be - "count which buttons enter the on state until a button is released" for example, the user wants to press 1,3 and 5 to represent the letter T - as soon as a key is pressed, the software should check for ON states and add them to a value, once any of the keys change to OFF the value is looked up in the table and passed to the serial port.
I think this should work - I got the code from Yerg2k excellent switchboard project which elegantly reads the keys with no false "bounces" - now I just need to modify it to do the looking up, but I am only a beginner coder!
Thanks again for your interest and advice - most helpful!