For a while we’ve been meaning to try out Jay Clegg’s TWI-video hack for the Peggy 2, and we must say, it’s pretty nifty. Using this routine, we can take webcam video (e.g., from our MacBook Pro’s built-in camera), sample it in a Processing routine, and send it to be displayed on the 625 LEDs of the Peggy 2.
Some months ago we wrote about Jay’s previous project: sending video to a Peggy 2 with a hardware serial port added.
While that’s pretty impressive, it’s also a bit invasive, since it requires rewiring the Peggy board. The new version of the project streams data to the Peggy 2 microcontroller over its TWI (also known as I2C) interface– a separate serial interface that’s available. An external Arduino board (or equivalent) sits between the host computer and the Peggy as a serial-to-TWI (I2C) converter.
While Jay used a stock Arduino board in his demo, we just used a hacked “business card” breakout board, wired up where the battery box normally goes. The important part– no matter which version you are using is that the two TWI interface pins SDA (aka “Analog 4”) and SCL (aka “Analog 5”) are wired together between the Peggy and the Arduino. It’s straight-across wiring, so that pins SDA of both chips are wired together, and pins SCL of both chips are wired together. (The boards also have to share a common ground.)
For our parasitic version, we also powered the board from the Peggy 2, so that we wouldn’t need an additional power supply.
Since there are two microcontrollers, you’ll need one program for each. You can download the programs for both at the bottom of this page on Jay’s site. One program runs on the Peggy, and just waits for (or displays) incoming video data. The other program, for the intermediary Arduino, acts as a serial-TWI converter.
When it runs, it takes video input from a connected webcam (subject to the limitations of the Processing video capture library). The data is converted to grayscale, and drawn as a 25×25 grid of round dots, simulating the Peggy display. (This works without a Peggy as well, just in case you want to play with it.)
Embedded below is a short video (without narration) showing the VideoPeggy in action. If you can’t see it here, click through to flickr for the video. Performance seems to be good at about 15-17 frames per second with 16 levels of grey.
Update: We’ve uploaded a version of the TWI-receive software for the Peggy 2, formatted as an Arduino sketch and verified to work on both the ATmega168 and ATmega328P. You can download it here.