Last chance to enter The Hackaday Prize.

AVR Tetris

Tetris, the timeless classic, is one of those concepts that someone will try to run on every conceivable hardware platform. I took on the challenge of programming a Tetris clone from the ground up using hardware I had on hand. At the heart of the build is an ATmega168 microcontroller. The game displays on a KS0108 128×64 LCD module with five momentary push switches to provide directional, rotational, and input controls. You can see the resulting monochrome action embedded after the break.

I had several goals in mind while writing the code for the game.  I wanted the code to be portable so that the size of the board and type of screen used could be easily changed. With that in mind I developed the trunk for a Nokia 3595 cellphone screen and a parallel branch for the graphic LCD. Originally I was working with an ATmega8 but upgraded so that I could operate at the 3.3v the cell phone screen required.

The firmware for the graphic LCD branch compiles to just over 6 kB which means it can still be run on a mega8. Also, the ATmega168 is the same processor used in the Arduino Duemilanove so another Tetris port is not out of the question. I just got a hold of my first Arduino so we’ll see if I find time to start a new branch in the code.

Comments

  1. Dan says:

    Even though there’s no audio, I’m still going to have the Tetris theme stuck in my head for the rest of the day…

    \good work, btw!

  2. yuppicide says:

    I wasn’t going to have the Tetris theme stuck in my head, but reading your reply I will now.

  3. yuppicide says:

    Do do de do de do do.. damn you! Great hack by the way.

  4. osgeld says:

    over the weekend I was looking at my 128×64 lcd on its end and though, hm … that would be cool for some games like tetris or even pacman

    good thing my thoughts pass by pretty quick, cause now I can just use this version and save a lot of grief

    Thanks!

  5. walt says:

    nice one! looks fun.

  6. Michael L. says:

    Very very nice work. I just ordered my first arduino ever (Duemilanove with an atmega328) so when it ships I might try this one out myself. The only thing I could think of would be to add a buzzer to play the theme :P

  7. supershwa says:

    Crap. Why did you mention the theme song? Now my day is doomed!

  8. Brent says:

    Really cool, there is another cool tetris using the atmega168 at http://depg.ca/

  9. Paul Potter says:

    Pure brilliance. I really want to do this when I get my Arduino.

  10. Ben Ryves says:

    Very nice. :-) I also wrote an Atmega168 Tetris and Snake game, which generates composite video output using a couple of resistors for playing on a TV screen – http://benryves.com/products/avrtvgame

  11. eric says:

    Speaking of Tetris, I made the theme like a week ago

  12. Rollyn01 says:

    dun da da dun da… dun da da dun da… Ummm, is it possible to love a theme so much and hate it just as equally? Now I have to go download both themes. Damn Russian brainwashing-like teaching tactics( read: the original purpose of the game).

  13. LED display says:

    seem a good one i like it

  14. Sören says:

    Great one!

    Here’s a tetris game on a 16×16 LED display:
    http://www.das-labor.org/wiki/Datei:Borg-andre-rot.jpg

    The Software for it can be found here:
    http://das-labor.org/trac/browser/microcontroller/src-atmel/borg/borgware-2d

  15. AvrLabCom says:

    Here is a similar project, but with display is used TV or LCD monitor from PC benryves.com

  16. Kodie389 says:

    Is it possible to get it to output in ntsc?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 91,159 other followers