Switchboard
A while back, I had an idea: What if you could control winamp with some external buttons? Well, I never got around to making it (which, for that time period, is no surprise).
Now that I have this Arduino, though, I have available to me a simple yet effective software-hardware interface. And, now I have more uses for such a thing, plus I envision this as being a product which could be produced to help differently-abled people.
(click picture to leave comments)
For a longer, more detailed explanation, as well as why this really benefits me, scroll down.

Functional description
There are four buttons and a rocker switch. You can see in the picture how they are arranged, and I think that this device’s purpose can be fairly easily deduced from a description of the functions available, through what we will refer to from now on as L1, L2, R1, R2, and “the rocker” (towards or away).
Winamp mode
- L1/L2 are for previous/next track
- R2 is pause
- Rocker (on) goes to “launch” mode
“Launch” mode
- L1 goes to “QuickKey” mode
- R2 goes to clipboard mode
- Rocker (off) goes to winamp mode (in all modes)
“QuickKey” mode (also selected by pressing R1+R2)
- L1 = Spacebar
- L2 = Enter
- R1 = Tab
- R2 = Backspace
- L1+L2 = Ctrl+Shift+Tab (previous tab in web browser)
- R1+R2 = Ctrl+Tab (next tab in web browser)
Clipboard mode (also selected by pressing L1+L2 [except in "QuickKey" mode])
- L1 = Copy
- L2 = Cut
- R2 = Paste
- R1 = Undo
- L1+L2 = Secondary clipboard paste
Functions are triggered when the button is let go. The two-button combinations were added after “launch” mode, so there’s certainly room for expansion in the current UI.

DETAILS
StickyKeys is a feature of Windows (and other OSes) which has saved my keyboarding experience since my problems of last year began. Before that, it was an annoying nag that came up whenever I accidentally pressed the shift key five times in a row. I never thought I’d be typing with one hand, though now that I do, I realize a few things. When typing with one finger, sometimes one must traverse the keyboard quite a bit to press certain keys. For example, the backspace key is quite a bit away from A, so a typo at the left side of the keyboard means having to move all the way to the right to hit backspace, then back to press the correct character. That sounds a bit lazy but in reality it could speed up typing for someone who does not have both hands available to type.
What if my foot could switch a backspace key? Or, even better, the spacebar, one of the most frequently-pressed key? But wait, there’s more! When typing with one finger, to copy one would press “ctrl” and then “c”, and likewise for cut/paste/undo/etc. Why not have a button for each of those functions? This could come in handy especially when doing tasks which require the use these clipboard functions a lot.
Also, switching between keyboard and mouse is slow, so when one button needs to be pressed in a few locations (selected using the cursor). For instance, indenting several lines -having the space bar at one’s feet, the mouse can still be used. For indenting or “outdenting” multiple spaces, another setting could be to have buttons press space two or four times, bring the cursor back that many spaces, and proceed to the next line. This way many lines of code can be indented quickly.
I used to play in a few first person shooter games, however I lost interest in them a few years ago. Still, if I would want to experience nostalgia, I could fire up Q2 or one of the ol’ Counter-Strike betas (my favorite, anyway). Problem is, with my only hand working the mouse, I would have no way of moving around with the usual axes (forward/back, sidestep, jump/crouch). With a switchboard, it would become possible to use that as input for a video game.
Having amassed 1001 ways this could be useful, I headed over to Radio Hovel to get an assortment of switches.

Two switches for the left foot, two for the right, and a rocker, for whatever. Spontaneous ingenuity led me to using a three-ring binder as a wedge-shaped “footboard” for which to mount the switches.
I’m impatient in some ways, so while waiting to get someone to drill holes for my project, I soldered wires on one end of the cable to headers. I must say, I’m surprised at how well it looks, for me doing it without assistance. Ground, and five wires for switches.

As the ATMEGA8 chip has internal pull-up resistors (which must be enabled by the software), all that was required on the switchboard end was a wire to each switch, and a common ground. Completed, a picture of this appears at the top of this page.
Now we need software. First, the Arduino end. The code is at the end of this page, as wordpress is being stupid about code tags.
This works much like a keyboard. Data is sent whenever the state of a switch changes. So, the receiving software is told when a button is pressed, and also when it’s let go. This should allow for combinations (press two buttons for a third function, hold one button while pressing another, etc.)With that code in place, we’re ready to write the control software. I’ve decided not to expend the time putting all of the programming details, but I’ll explain what features I did add.The main window shows what each button does. When a switch is pressed, it lights up on the UI. Most functions are performed when the button is released. Some buttons, upon being pressed, cause the UI window to come to the top (in view). The UI window automatically hides itself (under all other windows) after three seconds.
The default mode is winamp controls. In this mode, the left-foot switches are for previous/next track and the rightmost switch is pause.
(click picture to leave comments)
One of the right foot switches is unused in this mode. The rocker switch activates “launch” mode where different configurations for the switches may be selected.

Switching the rocker brings up this window. Flipping it back will return me to the winamp controls. There are three various modes with different bindings here.

As you can see, in clipboard mode the cut, copy, and paste functions are available. This is done by a “sendkeys” command, so it won’t work in certain applications (remote desktop).

This provides quick access to those frequently-used keys. Right now I’m still working on my coordination using these new keys. As I said before, the functions are triggered on release, so I can rest my toe on that spacebar switch while typing a word, and release it when I need a space. This seems to work well, when I remember that it’s there.

Here, there’s indent/dedent which adds/removes four spaces and moves to the next line. Clicking menu pulls up options, one of them being to set what the “custom” switch does. This page should give anyone a good idea of how this device works. As you might imagine, this is already making things quicker for me.
And how would I play a game, such as quake, with this? I’d have the arduino send back specific characters for buttons being pressed/let go. Windows XP has an accessibility feature which allows one to use a serial device as a keyboard. With the proper binds and aliases, the outside buttons can serve as sidestep, and another for forward/back, or jump, change weapon, etc. I know from my counter-strike days that scripting with aliases can make for very powerful, dynamic combinations.
Here’s that Arduino code:
/* Footkey
* ---------------
*
*/
// variable declaration
int sw[7]; // switches / their values
void setup(void) {
Serial.begin(9600);
int cnt = 2; // counter
while (cnt <= 6) {
sw[cnt] = 1;
pinMode(cnt, INPUT); // set to input
digitalWrite(cnt, HIGH); // enable pull-up
cnt = cnt + 1;
}
}
void loop(void) {
int cnt = 2;
int vin = 0;
cnt = 2;
while (cnt <= 6) {
vin = digitalRead(cnt); // poll the pin.
if (vin != sw[cnt]) { // has its state changed?
sw[cnt] = vin; // set the new state
Serial.print(cnt, DEC); // send which pin we're talking about
Serial.print(vin, DEC); // send what the pin state is
delay(100); // "debounce" switch
}
cnt = cnt + 1;
}
}
* A winamp library for visual basic 6 can be downloaded here. This is how to use it:
To find the window handle of a running winamp, do:
WinAMP_FindWindow
This only needs to be done once, but you will have to do it again if winamp is restarted. Commands are sent like this:
WinAMP_SendCommandMessage (WA_PAUSE)
WA_PAUSE can also be any of the following:
Public Const WA_PREVTRACK = 40044 Public Const WA_NEXTTRACK = 40048 Public Const WA_PLAY = 40045 Public Const WA_PAUSE = 40046 Public Const WA_STOP = 40047 Public Const WA_FADEOUTSTOP = 40147 Public Const WA_STOPAFTERTRACK = 40157 Public Const WA_FASTFORWARD = 40148 '5 secs Public Const WA_FASTREWIND = 40144 '5 secs Public Const WA_PLAYLISTHOME = 40154 Public Const WA_PLAYLISTEND = 40158 Public Const WA_DIALOGOPENFILE = 40029 Public Const WA_DIALOGOPENURL = 40155 Public Const WA_DIALOGFILEINFO = 40188 Public Const WA_TIMEDISPLAYELAPSED = 40037 Public Const WA_TIMEDISPLAYREMAINING = 40038 Public Const WA_TOGGLEPREFERENCES = 40012 Public Const WA_DIALOGVISUALOPTIONS = 40190 Public Const WA_DIALOGVISUALPLUGINOPTIONS = 40191 Public Const WA_STARTVISUALPLUGIN = 40192 Public Const WA_TOGGLEABOUT = 40041 Public Const WA_TOGGLEAUTOSCROLL = 40189 Public Const WA_TOGGLEALWAYSONTOP = 40019 Public Const WA_TOGGLEWINDOWSHADE = 40064 Public Const WA_TOGGLEPLAYLISTWINDOWSHADE = 40266 Public Const WA_TOGGLEDOUBLESIZE = 40165 Public Const WA_TOGGLEEQ = 40036 Public Const WA_TOGGLEPLAYLIST = 40040 Public Const WA_TOGGLEMAINWINDOW = 40258 Public Const WA_TOGGLEMINIBROWSER = 40298 Public Const WA_TOGGLEEASYMOVE = 40186 Public Const WA_VOLUMEUP = 40058 'increase 1% Public Const WA_VOLUMEDOWN = 40059 'decrease 1% Public Const WA_TOGGLEREPEAT = 40022 Public Const WA_TOGGLESHUFFLE = 40023 Public Const WA_DIALOGJUMPTOTIME = 40193 Public Const WA_DIALOGJUMPTOFILE = 40194 Public Const WA_DIALOGSKINSELECTOR = 40219 Public Const WA_DIALOGCONFIGUREVISUALPLUGIN = 40221 Public Const WA_RELOADSKIN = 40291 Public Const WA_CLOSE = 40001

