Introduction: Arduino Pong With TV Output

About: The RobotGeek team is a 6-man operation that wants to make it even easier to use Arduino to make electronics and robots. Check out our instructables and robotgeek.com for all of our awesome kits.

Here's a simple project that you can do to get acquainted with the TVOut Library, and using an Arduino with RCA Jack outputs! Pong is a classic. The foundations of video gaming start with two lines and a dot bouncing back and forth on a black screen. The Atmega328 is leaps and bounds more powerful than the original pong system (which was either quite a lot of transistors, or a chip with less power than a dollar store calculator), and we'll have no problem making a pong clone with arduino. If you want to make your own game with arduino, this is a cool place to start. Let's make Pong!

Step 1: Project Parts List:

You can build this with different parts, these are just the suggested ones for simplicity. Don't skip the Sensor Shield, it will save you loads of time, allowing you to skip breadboarding. Our wiring diagram will assume you're using the sensor shield. If you don't want sound, you can skip the Y cable and 2 of the RCA boards.

Step 2: Wiring

Follow the diagram to make your TVOut Console. Watch your jumpers, make sure they're set to 5V or you could destroy not only the RCA boards, but the input on your television.

Device Sensor Shield Port
Right Player Control RobotGeek Rotation Knob Analog 0
Left Player Control RobotGeek Rotation Knob Analog 1
Start Button RobotGeek Pushbutton Digital 2
Sync RobotGeek RCA Board 1 Digital 7
Video RobotGeek RCA Board 1 Digital 9
Audio Left Channel (on video pins) RobotGeek RCA Board 2 Digital 11
Audio Right Channel (on video pins) RobotGeek RCA Board 3 Digital 11

Step 3: Programming

Grab the RobotGeek Libraries and Tools from Github, and extract it to your arduino folder.

Open up:

File → Examples → TVOut → PongNTSC
and upload it to your arduino.

You're ready to play some pong! This program utilizes the TVout library, which handles drawing shapes, text, and bitmaps to the screen. It is a completely interrupt driven library that will output either NTSC or PAL composite. Pong isn't the only game designed using the TVout library! If you check out Nootropic Design, there are a good handful of games made, and they have a section devoted to helping you design your own! This makes for some great jumping off points on an adventure into making your own video games!

Step 4: Play!

So you might notice that the game isn't particularly challenging. Can you find out where the ball speed is in the code? What would happen if you changed the paddle size? Those sounds are kind of annoying, and there's no music. Could you use the TV.tone function to change that? What about changing the message that appears on screen at game over? Play around with the code and see what you can make happen!