After the publication of the Arduino VGAx library on GitHub done by Sandro Maffiodo aka Smaffer, I have reproduced and published on Instructable some of the most famous classical games. Recently I decided to put four of them together, in particular: Pong, Breakout, Bomber and a drawing toy inspired to Etch-a-Sketch.
The hardware is simply the same of my first Instructables: VGA Pong with Arduino Uno.
The only needed components are two potentiometers, two buttons, few resistors and a DSUB15 (VGA) connector. As usual, no supporting IC or special shields!
You can see the 4-in-1 games in action in this video.
The VGAx library allows to use four color with a resolution of 120 x 60 pixels, not many but enough for this retro-game “console”. The graphic is raw but, thanks to the use of the potentiometers, the games run smoothly. Simple sound effects are available too.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: How to Build Your Own "4-in-1 Games" With Arduino
First download " ArduinoVGAgames" code at the bottom of this page and copy it on your PC in a directory with the same name. Then download the Smaffer’s VGAx libraries from this link on GitHub. The easiest way is to copy them in the Arduino software subfolder named "libraries", to be immediately recognized.
Uploaded then the code in your Arduino (I tested Uno and Nano). A worning for low available memory is normal. If you do not have other errors everything is ok and you can immediately start to build your own console.
For this you need:
- an Arduino Uno Rev. 3 or an Arduino Nano 3.x
- a DSUB15 Connector, i.e. a VGA female connector or a VGA cable to be cut
- four resistors: 2 x 68 Ohm and 2 x 470 Ohm
- two 10 kOhm linear potentiometers (similar values are fine too)
- two buttons other two resistors (from 1 to 2 kOhm are fine)
- some piece of cable + breadboard or a strip board
- facultative: a piezo speaker
The schematic is reported at the beginning of this Instructable, together with an overview of the finished “console”. The speaker must be connected to analog pin A0.
I placed the Arduino board with the VGA connector in a wood box, which holds also the second player potentiometer and button, while the main player potentiometer and button are in a separate and smaller box.
If you decide to reproduce this toy, I appreciate if you write a comment or send a picture in the comment section below.
Step 2: Some Final Comment
Joining four games in one was challenging, due to the Arduino lack of SRAM, the real bottle-neck of the VGA performances.
The AVR microcontroller has only 2048 bytes available to store and manipulate the variables. On the other hand the VGAx library stores the screen variables in a 120x60 pixels framebuffer where each pixel needs 2 bits (4 colors), for a total of 1800 bytes.
Only 248 bytes are then available for the sketch variables but, in my experience, one should leave at least 100 bytes free to avoid instabilities.
The VGA standard has been officially put in retirement in 2015, for being substituted with HDMI, and nowadays is almost impossible to find a new monitor or TV that implements it.
The question is then: does it make sense to produce an Arduino game for this standard? Well, I believe the answer is yes! For this reason, nowadays, almost everybody has an old and unused VGA monitor, eventually 4:3, still working fine, since it has been replaced with an HD one. If you, as I do, feel sorry to throw in the waste a working yet obsolete device, you can convert it in an old style retro-gaming station by means of a bare Arduino and few other components.