close-circle
Close
0%
0%

ATmega Tetris

Tetris game on ATmega8 with LCD display

Similar projects worth following
Tetris game running on ATmega8 microcontroller with Nokia3310 LCD display attached

The aim of this project was to implement Tetris game as close to the original game as possible within the 1KB code limit.



The game has the following features implemented:
- optimized to 1024B of code (see build.log file attached as a proof or build it yourself)
- real random number generator using free pin ADC noise for next tetrimino randomizing (you will never play the same game twice)
- next tetrimino is shown on the bottom of the screen
- level dependent game speed (the higher level you are the faster tetriminos drop)
- 4 buttons: left, right, down, rotate
- game level indicator (there are levels from 0 to 63 shown as a bar on the right side of the screen)




Technical specification:

- ATMega8A-PU microcontroller running at 8MHz
- Fusebits used: High: 0xD1, Low: 0xE4
- Nokia 3310 monochrome LCD display with 48x84px resolution (PCD8544 controller)
- The game is developed in C language and compiled using avr-gcc 4.9.2 in Atmel Studio 7.0 IDE
- The project uses not connected ADC0 pin to capture the noise to use it as random values. These randomized values are used to select next tetriminos during game play. It means you will never play the same game twice.
- 5V power supply
- 6 classic Tetris tetriminos ("J","L","O","S","T","Z" -shaped), plus 2 non-classic tiles (3-pixel "I"-shape and 1-pixel "." (dot) shape)
- Due to the optimizations the source code might not be as easy to read as it could. I added many comments to the source code
- To drive LCD display I used and optimized existing PCD8544 driver downloaded from https://fandigunawan.wordpress.com/2008/06/18/lcd-nokia-3310-pcd8544-driver-in-winavravr-gcc/



BOM:
- ATMega8A-PU microcontroller
- Nokia 3310 monochrome LCD display
- 100uF/6.3V capacitor
- 1uF/35V capacitor
- 100nF ceramic capacitor
- 5x microswitch
- 8x 10KOhm resistor
- 100KOhm resistor
- bread board
- a couple of insulated wires to connect all the pieces
- 5V power supply


main.c

main game C source code (requires other files from src.zip to build)

C Source File - 9.54 kB - 01/04/2017 at 21:56

download-circle
Download

build.log

proof of 1024B size

log - 4.58 kB - 01/04/2017 at 21:25

download-circle
Download

src.zip

zipped source code + Atmel Studio 7 project

x-zip-compressed - 33.93 kB - 01/04/2017 at 21:24

download-circle
Download

  • 1
    Step 1
    1. Unzip "src.zip"
    2. Open "tetris.cproj" project file in Atmel Studio 7.0
    3. Build "Release" configuration

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates