Introduction: Tetris Clone With OLED SSD1306(I2C) for Arduino Nano / Uno

This Instructable is about getting Tiny Tetris running on a 128x64 OLED display using an Arduino Nano or Uno.

Step 1: What You Need.

Arduino Nano or Arduino Uno:

Nano

Uno

Display:

OLED I2C SSD1306

Keypad:

AD Analog Keyboard Module

Note: other key pads and switch configurations could be used but you would need to change the code.

Some cables to connect things:

Cables

Step 2: Uno Wiring

Uno wiring:

Note: the key pad shown represents the pad in the parts list, I have not built the one shown but if you did it would be easy to get it working, only a few small changes would be needed in the code.

Fritzing Part

Step 3: Nano Wiring

Nano wiring:

Note: the key pad shown represents the pad in the parts list, I have not built the one shown but if you did it would be easy to get it working, only a few small changes would be needed in the code.

Fritzing Part

Step 4: The Code

If you are new to Arduino have a look at this to get started:

How to have fun with Arduino

Code attached and on GitHub below:

Code on GitHub - this has the most up to date code including Art work and Sound!

There is still a lot to be done with the code, see below:

High score functionality.

[Done] Better key pad control code.

Decent random number generator.

[Done] Start thinking about adding sound.

Create a letter font, create a proper system for rendering numbers and letters.

Tidy up code and optimize for memory, sort out the globals and types.

Create defines for all the magic numbers but they are useful for now.

Step 5: Have Fun!

Comments

author
D6equj5 (author)2017-08-10

Hi,

I've stuck a 1306 oled disp on a Mega and loaded your code however all I get is like a star screen (random points not moving). Do I need to have the JoyStick actually plugged for it to work or have I missed something else?

Thanks

D6

author
BADFEED (author)D6equj52017-08-11

Hi,

you don't need the joystick plugged in for it to work.

I have never tried it on a Mega but it should work.

Have you tried other display library's with the 1306 on the Mega?

I assume the 1306 you have is I2C interface?

regards,

author
KunI3 made it! (author)2017-03-28

hello, badfeed. i have a question, if the change the lcd like that? how to program that?

thank you

Tokoduino5.jpg
author
BADFEED (author)KunI32017-03-29

Hi,

I don't know anything about that display and I imagine the system for comunicating with it is different to the SSD1306.

Sorry I can be of more help.

good luck with it though, nice looking display..

author
Lintang_Wisesa made it! (author)2017-01-07

It's awesome! I made it w/ joystick/thumbstick controlled, demo: https://youtu.be/jGtNyWtdwFM

titrisok.png
author
BADFEED (author)Lintang_Wisesa2017-01-07

Cool :)

Good job getting the thumb stick working with it!

author
SarahH25 (author)2016-12-13

another christmas present idea!

author
DIY Hacks and How Tos (author)2016-09-17

Fun project for teaching people about Arduinos and displays.

About This Instructable

5,114views

28favorites

License:

More by BADFEED:Tetris Clone with OLED SSD1306(I2C) for Arduino Nano / Uno
Add instructable to: