Take one Lilypad LED-matrix top (you thought I'd forgotten, hadn't you?), add one SparkFun Wearable Keypad, and voila! You get one fun interactive top!

The devil's in the details )

It's all controlled by the push-button. Initially all LEDs are off.
- Push once; all LEDs are on.
- Push twice; you get the random LED twinkle pattern.
- Push thrice; you get into keypad controllable mode (denoted by the keypad lighting up). You press the centre SparkFun-logo button to clear the board and pick a random starting LED. Then you can use the four directions to draw in lights.
- If you press the push-button a fourth time, you stay in the keypad mode, but the timing changes and the pattern becomes a chase-sequence.
- Pressing the push-button again brings you back to the beginning, with all LEDs off. (But so long as you don't turn off the battery, your pattern is still kept in memory.) Here, have a look.

If you happen to be at Darklight next weekend, come find the tog guys, and you can have a go yourself :)
I admit I can be a bit of a sucker when it comes to electro-textile stuff. I see the word 'wearable' in front of any traditional electronic component and I have to investigate. Which is how I came to possess the Wearable Keypad from SparkFun. I finally got around to using it recently, so here's the low-down.

It's a thick piece of rubber, glued together and sealed with silicon gel type stuff. It has six wires (about a metre long) coming from it. One wire is not connected (NC), one is ground (GND), one is for setting the brightness of the red LEDs behind the keypad (LEDR), and the other three (p5.1, p5.2, p5.3) are for the button presses. And as mentioned in the comments (of the product page) the order of the wires is backwards to that as shown in the datasheet.

Wait, you say, three wires for five buttons? What's going on? Seems to be a bit of fancy multiplexing, although the details are beyond me. I have however, managed to get it all to work for me, and have edited the Example Code provided by SparkFun to, shall we say, neaten up things a bit? Basically, I found that in the provided code I was getting spurious results; when I'd press 'down' I'd often get a 'left' or 'right' for no apparent reason. So I've added a few extra checks, that while they may slow the code down a bit, ensure clean detection of button presses. All the extra stuff to do with the LEDs I've stripped out. You may not need it, but here it is in case you do. (Also, your millage may vary, and as such you may need to edit this code to work just right for you.)

But give the SparkFun example code a go too. It's oddly satisfying to play with the LEDs.

Let's go )

I have to say though, I was a bit surprised that the keypad came with such long wires, and unfinished ones at that. While it works well with an Arduino Uno, it doesn't do so well with the Arduino Lilypad. I'm going to have to come up with a suitable interface to get the two to play well together. (And yes, this is part of a larger project...)
◾ Tags: