Introduction: Play Tetris Game With Arduino

About: ElecFreaks is an open design house founded in March 2011. Our goal is to create rapid prototypes and give small-batch manufacture solution for makers and startups. With over 50% staff as engineers and expanded…

Develope Tetris game via Arduino and learn how to develop a simulated game quickly to reproduce the classic. Tetris games help maker to study the usage of the LCD screen and Arduino program.

Demo From:

Arduino advanced kit provided by ELECFREAKS is based on our starter kit to expand more and more popular modules owing the characteristics of plug and use without any requirement of soldering. We have well prepared six courses for learners to learn the usage of modules in an intersting environment which is better for stimulating your thinking mind. For example,Tetris games help us to study the usage of the LCD screen and Arduino program. Color picker used can help us to learn the color sensor as well as BLE Bluetooth communication and Android interface development ... Practical Course included LCD screen, sensor, MP3, BLE, WIFI, Android development, and image interaction (processing), make you open-minded!

Step 1: Step 1 Materials List

An Arduino maminboard,an analog keyboard, an LCD display

*1xFreaduino Uno;



Step 2: Step2: Working Principles:

Parameter and IO definition:

1.5V power supply to mainboard

2.TFT的VCC-GND-CS-RESET-AO-SDA-SCK-LED successively connected with power supply(V)、ground(G)、D6、D5、D4、D3、D2、power supply(V)of the mainboard.

3.ADK access to board analog A0, G (ground), V (power supply), S (IO port).

Working principles:
A.First of all, you need to set the size of the smallest grid. To set the pixels of the side can change the size of grids and calculate how many grids can be layed to the whole screen.

B.TO get a variety of graphics by changing different placement of grids. We have set 8 graphics in the game and we need to encapsulate it with array, because the biggest is strip which occupied four grids. There are four directions in each graphic and 4x4 two-dimensional array can be used to encapsulate the graphics data. That the array value is zero or not is used to make sure whether there is a grid existed.

C.When you put the whole screen as a large array and every grie is one of the elements, then you will be able to control the position of each graphics displayed on the screen and can calculate if it is in the end, beyond the border, or all of the elements has been filled in the line, then eliminate them.

D.If you are already clear of all this, just add a button then. Reading its value can be used to control the up and down about the game graphics. Well, introduction is over, let's start programming it.

Step 3: Step 3: Code