As per the TGIMBOEJ rules, I took some junk treasures and replaced it with a bunch of my own junk stuff.

And, as per the rules, I took a handful of photos of some of the stuff I pulled out. Not all.

I did not take photos of the stuff I put in. That is for the next person on the list to discover fully. Some vague clues, though: I added some antique semiconductors, some power management related componentry, some completely random small bits of goodness, a working caseless gigabit switch, and a purely mechanical device that is gloriously elegant in its implementation. And some other stuff, too.

The main loop spins forever and is generally the bit of code that updates various output ports based on program state. It might likely also read inputs, too. And it might contain bits of code that delays execution for a while. And it is very likely rife with conditionals that’ll cause any given pass through the loop to very in execution time.

Not a very good place to do time sensitive stuff like, say, debouncing a button press or responding to other user events.

Each on/off port is represented by a single bit. So, each of the pins in PORTA, PORTB, PORTC, or PORTD — assuming they are in straight digital input/output mode and whatever AVR chip you are targeting has enough pins to have 4 port sets — will be controlled by a single bit in one of four bytes.

Clearly, some macros to toggle bits are in order. Now, it turns out that macros to toggle bits are a big source of contention amongst the AVR development community. They hide too much magic, or so they say, and, if you are going to be programming embedded systems, you ought to be comfortable with C level bit twiddling, damnit.

Thus, I should have enough parts to drive a solenoid or flash-lamp from the AVR micro-controller.

First, though, I’ll flash some LEDs in response to button presses, though. All one voltage and relatively little chance of blowing up chips, bulbs, or shocking myself.

Once that works, I’ll wire up higher voltage / current drivers. I figure I ought to be able to both replace the flipper drivers with a much more maintainable system while also adding some automatic diagnostics that will light some LEDs inside the pinball when the flippers need to be rebuilt or maintained.

The Atmel AVR micro-controllers are awesome. They cross three particular barriers to entry that I arbitrarily chose prior to screwing around with micro-controllers.

Specifically:

Price: $10 per useful part The Atmel series ranges from less than $1/part to a bit north of $10/part for the über-deluxe controllers. The ATmega168 in this kit can be had for less than $5/each and includes 23 I/O lines (6 of which can be used for ADC), 16K of program memory, and can run up at speeds up to 20MHZ.

Easy & Powerful Programmability (on a Mac) Code for the Atmel series of chips is written in C and compiled quite easily via gcc. The ObDev folks have made an easy to install package available. It just works. Better, the chips support in system programming (without sacrificing pins for I/O!) and, thus, “build and run” in Xcode re-loads the code on the target chip without having to either power down the board or remove the chip from the circuit. Edit-compile-run is very very fast.

The code, itself, is pretty straightforward. The header files provide all the #defines needed to deal with all the random I/O based hardware functionality quite straightforward. The chips, themselves, are exceptionally flexible, with the ability to reconfigure what pins do what in software.

The hardest part is remembering which pin maps to what random #define’d symbol.

The Atmel chips are, in fact, the same chips (almost the same exact chip — the proto boards use a slightly less expensive part in that it doesn’t have quite as many I/O ports) used in the Peggy Board (also from EMSL). I picked up the ladyada programmer and grabbed the source from EMSL.

I had simple animation up and running within a couple of hours, most of that time being consumed by dealing with the now fixed USBTiny programmer bug. Not much longer after that and I had a pretty neat line based animation.

Which brings me to this kit: This credit card sized board is designed quite specifically for prototyping ATmega168 (and several others) based projects. Beyond including a bit of room for adding a couple of 8-pin DIPs (or other random components), the silk screen fully documents the various mnemonics associated with each pin.

First project?

I’m going to build modern style flipper replacement for ’80s and early ’90s Williams/Bally pinball machines. The old school flippers require more maintenance and tend to fail gracelessly, taking out other discrete components upon failure.

This board is total overkill. I really only need an 8 pin Atmel controller per flipper; maybe one chip for both flippers, if I optimize.

But at $9/each for the board, controller and discrete components (including shipping and CA tax) in lots of 10, I might just stick with building it out on the EMSL prototype board.

As with many EMSL projects, everything is open source. The board is single sided and easy to etch, but silk screening on the various documentation bits would be difficult.

Better yet, though, is that the fine folks of boston — the level headed public that makes the city such a great place — are celebrating the first annual “Aqua Teen Day” by decorating the city with LED art.

On January 31st, 2007, the authorities in Boston completely lost their minds. It wasn’t the first time, but this particular date was heavily reported and even the most head-in-the-sand die-hard “OMGWTFBINLADENFTChildren!!!one!!!” fear mongers found it ridiculous.

The results are just stunning. And effective. I brought the boards into work on Monday and, on the way home, stopped for a beer with boards in hand. Several folks asked about them and, upon explaining the history of the boards, they became just a touch more enlightened as to the stupidity of certain leadership and just a slight bit more inclined to learn more and vote accordingly.

Mission accomplished. With laughter included.

(The kits were a special edition from EMSL — you’ll have to contact them for availability. The LED “peg board” is generic; you can lay out the LEDs anyway you want to make any kind of similar display, including a “charlieplexed” mode that allows simple animations. I believe EMSL will be offering the generic form of the kit sometime soon.)