In an effort to learn more about the capabilities of Atmel's range of "tiny" AVR microcontrollers I decided to build clone of the popular "Simon Says" game using an ATtiny45.

The completed circuit (click for larger version)
The gist of the game is that it blinks out a pattern using the LEDs and you simply have to key in the same pattern to advance to the next level. The patterns get longer as the game goes on in order to increase the difficulty.
Hardware
My challenge was to use as little hardware possible to make a working game. I started by selecting the smallest microcontroller I had, the 8 pin Atmel ATtiny45, followed by 4 normally open switches, 4 LEDs and 8 resistors. The board is powered by 2 AAA batteries, and there is no on/off switch. The circuit can always remain powered on because I took take advantage of the AVR's "power down" sleep mode. When the unit is "sleeping" it only consumes 0.2 micro-amps of current.
Since the AVR I'm using only has 6 I/O pins, each LED shares a pin with a switch in the following configuration:
This allows me to use a single pin as both an input and an output. The only downside to this configuration is that you can't simultaneously use the output and the input, but this is acceptable for my application. Also, every time the user closes the switch the LED will light up, but this is also not a problem for my application. In fact, it gives the user a visual cue that let's them know they pressed the button which means I don't have to do that in software.
The full schematic is available at the end of this post (not that it's much more complicated than what you see above).
Software
As is customary with AVRs, the software is written in C using the tools from the AVR Libc project. I tried to take advantage of as many features of the ATtiny45 as possible to make this project a little more interesting. The seed value for the random number generator for instance is generated by using the analog to digital converter. The game saves power by powering down the AVR after a preset timeout (using one of the 8bit timers) and game progress is never lost because roughly every 4 seconds the game state is saved to the AVR's non-volatile EEPROM memory.
The random number generator is a simple linear feedback shift register using a Fibonacci feedback function (see the wikipedia article for all the gory details). To keep things interesting, the random number generator is seeded with a random number each time the device is reset. Generating the random seed value is actually not that difficult, but it is time consuming (for the microcontroller). All ATtiny45's come with a built in temperature sensor which can be read using one of the analog to digital converter channels. It's a crappy sensor (accuracy of ±10°C) but if we sample it really fast with the ADC (to get as much noise as possible) a good 30-40 times in a row, we'll get a nice big kinda-random number which is temperature dependent!
Saving power is pretty easy, most of the AVR's peripheral devices can be powered down and which means that they only need to be using power when you need them. The ADC for instance is only powered up for reading the temperature sensor then it gets shut down. I even shut off the timer before putting the device in it's "power down" mode, which is why it can consume such little power while sleeping.
Downloadables