Introduction: VGA Pong With Arduino Uno
I have repruduced a color version of the classic Pong running for a VGA monitor, using a bare Arduino Uno.
It is for two players and it has sound too. It has four colors and a resolution of 120 x 60 pixels.
My goal was to avoid any special shield or support IC!
I just used few resistors, a DSUB15 connector, a pair of potenziometers and buttons. The Arduino board and the others components are placed in two wood boxes. The second player paddle is connected to the main block by means of a recycled USB cable. Pictures of the whole "console" and a simple schematic are shown at the beginning of this video:
In the past I have reproduced the B&W version for TV, using the TVout libraries...
...but now, insted of the TVout library, the color Pong is done using the VGAx library recently written by Smaffer.
You can read further the details in this Arduino forum
Instructions to built your own Color Pong with Arduino
In brief, here you can download the latest code version, then you need the VGAx libraries from Smaffer on github published here.
NB it seems that the VGAx library is fully compatible only with Arduino IDE 1.6.4. Older or newer versions may not work properly or work at all.
Once you have the code uploaded an an Arduino Uno (I have Rev. 3) without errors, you can start to build your own console.
You need:
- an Arduino Uno Rev. 3
- 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 potentiometers
- two buttons
- other two resistors (from 1 to 2 kOhm are fine)
- some piece of cable
- facoltative: an USB female plug and an USB cable for the second player, or any other connector/cable with four wires
The schematic is reported at the beginning of this Instructable, together with an overview of the finished consolle and how the game looks on my TV.
I placed the Arduino board with the VGA connector in a wood box, which holds also the first player potentiometer and button. I used a second smaller wood box for the second player and I decided to connect it to the main one by means of an USB female plug and an USB cable. You can use any other connector/cable wich contains at least four separated wires.
Enjoy!
11 People Made This Project!
- DascaluMihai23 made it!
- mowgli27 made it!
- Pladask made it!
- desoppere.frank made it!
- kkant2291 made it!
- RonnelM4 made it!
- tejanihiren1991 made it!
- tejanihiren1991 made it!
- Sunr4 made it!
See 2 More
44 Discussions
4 years ago
Hello!
Nice projects, thank you!
Is it possible to put 4 your games in one sketch? It would be great!!!
Reply 4 years ago
Thank you for the compliment!
I think it is not possible, almost each game uses all the available memory for the variables and simply putting two or more games together would overtake the 100% of it.
But it would be possible to built a single "consolle" with four buttons and two wheels compatible with all the games, one has just to re-map buttons an potenziometers in the code. I plan to do that as soon as I have time, may be during the Christmas holidays. You just need then to upload the code in the same device.
Reply 4 years ago
It`s true, but if we choose ONE game in start menu (when it powered up or by pressing a reset) - we don`t need a room for variables of ANOTHER games.
About "consolle": I think, it needs one universal connector for 2 types of the manipulators - pot-s or buttons.
Reply 4 years ago
well, it is not so simple. If you join two games in the same sketch (each one with its own variables), the Arduino memory is occupied from the whole variables as soon as they are defined, even if you do not really use the ones for the first game when you play to game two.
The good news is that many variables can be used for one game or the other, you just need to assign theme one value or another, and this save space.
I have a working sketch now where one can choose between pong or breakout, and I plan to add more, but it will take time.
Reply 1 year ago
And if you put a SD card module for expand the memory and the arduino ges int the card cath a game whn we "quest" him to do this ?
Or an EEPROM?
1 year ago
You can send me a diagram and the code for the B&W and TVout version?
Question 2 years ago
Boa Noite... Poderia me passar a programação deste projeto?
Answer 2 years ago
http://forum.arduino.cc/index.php?action=dlattach;topic=328631.0;attach=135889
Question 2 years ago
it worked but there is flickering. suggest how to get rid o it. thnx
Answer 2 years ago
Try different Arduino IDE. I am usinge version 1.6.4
2 years ago
How to align this to center and get rid of the distortions?
2 years ago
Hi. Nice Project :)
Can I use this game for my design project ? thanks.
3 years ago
Hello
We have uploaded the code to the Arduino board but the monitor is showing no signal
Reply 3 years ago
Dear Pruthvi_96, which Arduino IDE do you have? it seems that the VGAx library is fully compatible with IDE 1.6.4
4 years ago
Hello!
I love Pong and decided to build this as my first Arduino project.
I want to make a table with a screen in so to players can sit on each side and play.
I have got it working but I want to changes, maby someone can help me?
1: I want the green bar to go the oposite way when i turn the knob/potentiometer. Where do I change the code?
2: I have a 4:3 LCD. Is there a way to change screen resolution? Or even better, expand the borders of this pong code?
Reply 4 years ago
Dear Pladask, for question 1: the easiest way should be to change in
void processInputs() {
buttonOneStatus = digitalRead(BUTTON_ONE_PIN);
buttonTwoStatus = digitalRead(BUTTON_TWO_PIN);
wheelOnePosition = analogRead(WHEEL_ONE_PIN);
wheelTwoPosition = analogRead(WHEEL_TWO_PIN);
buttonStatus = buttonOneStatus || buttonTwoStatus;
}
to
void processInputs() {
buttonOneStatus = digitalRead(BUTTON_ONE_PIN);
buttonTwoStatus = digitalRead(BUTTON_TWO_PIN);
wheelOnePosition = 1023 - analogRead(WHEEL_ONE_PIN);
wheelTwoPosition = analogRead(WHEEL_TWO_PIN);
buttonStatus = buttonOneStatus || buttonTwoStatus;
}
I cannot test it at the moment, let me know if it works.
For question 2 I have no answer. One of the main issues with the VGAx libraries is to center the picture, the best way is to use the center feature of the monitor, when available. The resolution (120 x 60 pixels) is more or less the maximum for the Arduino Uno capabilities, and it is not possible to use all the monitor surface. The yellow borders are the maximum extension available.
When you finish your project I would really appreciate if you can publish here a picture!
Reply 4 years ago
Hello Rob Cai !
I have finally tested your code and it works perfect! Thank you!
I have so many projects (non-arduino related) going on at the moment and I'm not great with wood, but i hope I can start with the box to put it in soon. I will post a picture when it's ready ;-)
4 years ago
My code compiles and uploads, but my monitor still says no signal. What could be wrong?
Reply 4 years ago
Nevermind, I made a simple wiring mistake. It works great! Thanks for this tutorial!
4 years ago
Worked perfectly! Thank you so much dude! Just one question: in order to increase the speed of the game, do I just need to edit this lane
#define MAX_Y_VELOCITY 0.1
right?
Thank you so much, tonight I and my friends felt like a 70's friends group *__*