I finally got around to uploading pictures and debugging all the code... so I figured I'd post some pictures of the ButtonShield I built here too, in my attempts to make my Arduino do things it definitely wasn't meant to do originally... which I think is the whole point of Arduino in the first place. I spent a bunch of time building and debugging the shield, and my fingers are still sore from manually "picking and placing" all the buttons with eyebrow tweezers...
This is a little shield that has a 4x8 pad of buttons, and a space bar and a shift key in the lower left that has two white LEDs that are either on or off to indicate whether the shield is in Mode A or Mode B. Depending on the mode, it uses a different set of pins to communicate with the Arduino, so it can "get out of the way" of other shields (and so it doesn't clobber them).
Here's a zoomed in photo of the shift key's LEDs:
And this is what it looks like when it's in shift mode:
Chris and I made a bunch of them by hand, and tried to learn how to use a "homemade" solder reflow (toaster) oven to assemble them:
The shield also has a backlight on the underside, which is controlled with an SPDT switch (the other switch is to set the shield in either Mode A or Mode B):
Omar, Chris, and I built an Arduino library file to abstract all the backend code, so the function to read a button is pretty clean (there's a buffer too, in case buttons are pressed faster than the Arduino can poll them):
#include < ButtonShield.h >
ButtonShield buttonsA = ButtonShield(0); /* Created a new ButtonShield on Mode A */
ButtonShield buttonsB = ButtonShield(1); /* Created a new ButtonShield on Mode A */
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print("ModeA: ");
Serial.print(buttonsA.readButtons());
Serial.print(" ModeB: ");
Serial.print(buttonsB.readButtons());
}
There are a couple of videos up on YouTube too of the shield in use (since I can't remember how to embed youtube videos on the forum)...