The Peggy Strikes Back

Wednesday, July 09 2008 @ 12:35 AM PDT

Contributed by: Windell

Automatically generated Peggy Code

Today we have an update on our Peggy 2.0 Light Emitting Pegboard project, with (1) a new and improved version of the Peggy2 Arduino library, (2) links to several awesome examples of Peggy hacks-- including a full-motion video hack, and (3) a new GUI application example that lets you display an image on the Peggy without writing a single line of code.

Let's start with the hacks!
    1. Art Dahm has written a digital clock application, an animated "Invader" sign, and an interrupt-driven Arduino display library for Peggy 2.0, all with posted code. These are definitely worth a look! [LINK]


    2. Geoff Harrison has turned Peggy into an animated analog clock, that keeps time even when the power is off. And, Honest Abe shows up in Peggy form too. Nice! [LINK]


    3. Aubilenon, zsazs, and leviathan wrote a neat demo called "Ledtro" on their Peggy-- Whoa! (Updated: New link with code posted!) [LINK]


    4. Taking this to the next level, Julien Gachadoat and Michaël Zancan of 2Roqs sent in this awesome video of animations on their Peggy. They were also kind enough to let us incorporate some of their code into the new version of the Peggy2 Arduino Library. The 3d rotating wireframe cube in the video is one of our new code examples! [LINK]


    5. And, taking the cake, Jay Clegg hacked a hardware serial port onto his Peggy, mashed it up with Quartz Composer (!) and managed to get scrolling text and is the first person to get real-time live-motion grayscale video running on his Peggy-- direct from a webcam(!!). He's posted a complete how-to, including videos-- go take a look: [LINK]



And now the Arduino Library update:
Today we're releasing a new version (0.30b) of the Peggy2 Arduino library, which now includes 12 example sketches. The biggest change from the last version of the library is that we have incorporated a line drawing routine contributed by Julien Gachadoat and Michaël Zancan. This lets you draw a line on the Peggy by using commands of the form Line(x1,y1,x2,y2), or by commands like MoveTo(x,y) and LineTo(x,y). We've also included example code for the new functions, including (as we mentioned) a version of the 3d rotating wireframe cube that's in his video.

You can download the latest version of the Peggy2 Arduino Libary on this page, and the gory details about what the functions are and how to use them are spelled out here. This is an open source project. Your code contributions, hacks, and suggestions are welcome indeed.



Lastly, we have a new GUI application example to show off.

One of the outstanding issues with microprocessor-based systems like the Arduino and the Peggy 2 (which shares the same AVR-based architecture) is that they require at least a little bit of programming to do much of anything. While the programming for these systems is about as easy as it gets (for C-like systems) it's still quite a barrier for some people to get past. For example, to turn on a specific set of LEDs on the Peggy 2.0, you might run an Arduino program that has a bunch of commands like this:

    frame1.SetPoint(5,8);
    frame1.SetPoint(14,8);
    frame1.SetPoint(10,10);

which would turn on the LEDs at (x,y) locations of (5,8), (14,8), and (10,10), assuming that you set up the program correctly-- don't forget your semicolons, initialize the frame buffer, clear the screen when you are supposed to and refresh the display. To those of us who program things, that's nothing out of the ordinary or remotely intimidating. However, for everyone else, it's almost too much to ask.

We would like to reduce the barriers to entry so that more people can enjoy playing with microcontrollers and LEDs, so here's another approach. We have written a graphical application in the Processing environment that generates a complete Arduino sketch as its output. The program is called PeggyDraw, and the output is a complete Arduino program that you can use to put a simple picture on the Peggy 2. You can download PeggyDraw.zip from the Peggy page on Google Code.

PeggyDraw

To use PeggyDraw, you'll need both the Processing.org and Arduino software packages installed. These are free cross-platform development environments. (I have Processing 0135 and Arduino version 11.) When you open PeggyDraw from within Processing and run it, you'll see a window like this one. It looks like the Peggy display, and you can click to draw or erase the dots on the screen. (This is a bit like the Peggy Planner except that it's oriented towards figuring out which LEDs you want to light up, rather than where you want to put which LEDs of different colors.)

PeggyDraw has only one other I/O method-- a button marked "Save." When you click it, it generates a subdirectory called "PeggyProgram" within the directory where PeggyDraw is located. Inside this folder is the PeggyProgram.pde file, which you can open from within the Arduino environment and directly install onto your Peggy.

Automatically generated Peggy Code

Doing this, you can program an image onto Peggy-- like so-- without ever touching code.

As implemented thus far, it's a very simplistic program. However, we think that simple programs like this one that automatically generate useable Arduino code may be an interesting approach to further reducing the barriers to entry-- And it certainly leaves plenty of room for improvement!


Update: We've released PeggyDraw 2!

Comments (5)


Evil Mad Scientist Laboratories
http://www.evilmadscientist.com/article.php/peggystrikesback