Runner Up in the
My name is Patrick McCabe and this is my first instructable. I am currently a 16 year old high school student who loves electronics, robots, circuits, and programming. I hope you find this helpful.
In this instructable I will be showing you how to make a small pong console (I guess you could call it that). You can see the above video for a demo of it and the 2 videos near the end of this instructable that dive more into the programming and functioning of the game. Make sure you check out the notes on the pictures in this instructable that further clarify the build.
The basic parts of it include an array of 6 8x8 LED matrices that form the screen of it, LED matrix driver ICs, 2 custom controllers, a small wooden cabinet, and an Arduino .
Tools you will need to build this include:
- Electric drill
- Soldering Iron
- Hot Glue Gun
- Multimeter (never hurts to have around)
- Philips screw driver
- Wire stripper
- Diagonal cutters or the like for clipping leads and wire
Having some previous experience in programming an Arduino microcontroller, soldering, and basic electronics would not hurt to have when trying to construct this.
I will get to the parts as I show you how to build each section of the whole project.
Step 1: The Display Breakout Board
Like I have previously stated, the display is constructed from 6 8x8 5mm LED matrices. I chose to purchase these on eBay (seller "vogue_valley").
It is going to take a little more than luck to control these using an Arduino Duemilanove or Uno. A LED matrix is wired so that a common pin controls the anode or cathode of a row or column. This allows the matrix to be controlled using just 16 pins instead of 64 individual ones. However there is another trick that has to be done when controlling a LED matrix, and that is to light up a single LED at a time. When LEDs are wired in a matrix, there are locations where if you light up 2 LEDs a third one might light up too. To avoid this, each LED is turned on and off quickly.
I chose to use an IC made by Maxim IC called the MAX7219CNG. This will allow each individual LED to be addressed in the matrix. These can be purchased at Sparkfun Electronics . Here is the datasheet. This IC was made to control a single 8x8 LED matrix. We will be using 6 matrices so this project requires 6 of these ICs. There is a nice library that was created for these that will aid in the programming of this project. This IC and library takes care of lighting up which LEDs that you want to light up without worrying about turning them on and off quickly like I explained. This will allow us to easily create and display images and worry about the pong side of things and not about all the finer details of displaying the image.
Now the IC needs to be connected to each matrix using the correct circuit. I designed a simple breakout board for this IC. I am not an electrical engineer, but the schematic you see in the pictures is pretty much what I understood from this page . Not really that complicated. I made this in Eagle and have uploaded my schematic and board files for you. Basically there are headers for the communication pins and for the output pins that go to the matrix. There are 2 capacitors on the input power and a resistor that sets the current for the LEDs. I used a 1K resistor for my application which worked fine.
So once you have the files, you can order the PCBs (printed circuit boards) from a batch house, I use Seeedstudio which will cost about $10 for 10 PCBs, or you can always create the circuit on a prototype board if you choose. You can see some images of my finished PCBs in the pictures.
You can order the parts needed to assemble the breakout boards from Digikey .
The parts needed are:
- 6 10uF electrolytic capacitors
- 6 0.1uF non-polarized capacitors
- 6 1K resistors
- 6 24 Pin IC sockets
- Optionally you can use headers instead of soldering wires directly to the boards. I did not.
Now solder these components on to the break out board. This is a pretty simple step. You just have to make sure you put the polarized electrolytic capacitor in correctly and line the notch in the IC socket up with the notch in the silkscreen of the PCB. See the pictures for the soldering step. When you are done soldering, you can insert the MAX7219CNG right now or wait until after you solder the matrix in place, which will be next, so you do not damage the IC in any way.
Step 2: The Display Final Assembly
So you should have the break out boards soldered together, but you have yet to attach the matrices to the boards. We will do that in this step and more. I actually found this step to be the hardest. I could not interpret the drawing that was supposed to show the pinout of the LED matrices, so I came up with my own.
I have uploaded some photos showing the bottom of my display. On the underside of the display you can see all the wires and the different matrices. Now there is another photo of the bottom of the top left matrix, this will be my example. As you can see, I labeled one pin "1" and another pin "9". Now the best way that I know of to tell the locations of these pins is by looking at the circuit inside the the clear back of the matrix. You can see the traces inside of there. The traces will allow you to tell which pin is which by comparing your matrix to my labeled one in the picture. Now there are 8 pins in each row. The right side is labeled from 1-8 (top to bottom) and the left side is labeled from 9-16 (bottom to top). This is just my way of labeling it. If you know the actual way, by all means wire it how you know it.
This matrix gets attached to the breakout board using my labeling like so:
Matrix Pin: Breakout Board Pin:
You can see that the boards need to be wired on the left or right depending on which side of the display the matrix will be on. You can wire 3 on the left side and 3 on the right. I chose to put 2 on the left, 2 on the right, and 2 on the bottom. So wire all the matrices up to break out boards and then use hot glue to glue them together to form a display. Do this by applying glue to the edge of the matrix and then attach that to another matrix. If you have a matrix with the breakout board on the left then you need to glue this to a matrix with the breakout board on the right and vice versa.
Finally there are a few last connections to make. The "Din" of the top left matrix's MAX7219CNG breakout board will be what is wired to the Arduino. The "Dout" of this gets wired to the "Din" of the top right breakout board. The "Dout" of the top right gets wired to the "Din" of the middle left matrix's breakout board. The "Dout" of the middle left matrix breakout board gets wired to the "Din" of the middle right matrix breakout board. I assume you see the pattern now. Continue to wire the boards together in this fashion until you get to the final, bottom right matrix. The clock and load pins of each board all get connected together. So unlike the data pin, the clock and load pins are all shared. We will connect these pins to the Arduino later. For now we are done with the display.
Step 3: Make the Controlling Paddles
This would not really be pong with out some kind of controller paddles.
The parts I used to make these are:
- 2 Project boxes
- 2 Potentiometers
- 2 Knobs (Silver or Black )
- 2 5mm LEDs (These are available at a lot of places. Diffused ones will work the best for this application)
- 2 1k Resistors
- 4 Audio jacks (2 for the controllers and 2 for the cabinet.)
- 2 Audio Cables (This one is kind of too long. Available a lot of different places and lengths)
- Red, black, and green wire to make connections and stay organized
- Heat shrink tubing
The first step is to drill some holes in the project box. The size of these holes will be left to your judgement, but normally it is pretty easy to hold something up to a drill bit and see if it is the right one to use or if you need a different size. One hole needs to be drilled in the middle of the lid for the potentiometer to stick through. Another hole needs to be drilled in the middle of the front of the project box for the audio jack to bolt onto. Finally a hole for the LED is drilled near the edge of the lid. This LED will just be used for power indication.
The next thing to do is to bolt the potentiometer in place. It bolts onto the hole in the middle of the top of the project box that was drilled.
Then, using hot glue, glue the the LED into place. I glued it in so that a little bit of the LED was sticking out of the top of the project box. Now we can start to wire the LED up. The longest lead on the LED is the anode pin. I trimmed this lead down and soldered the 1K resistor on to it. Then a red wire gets gets soldered to the other end of the 1K resistor. Use some heat shrink to cover up this connection to prevent shorting the leads of the LED. Then shorten the other lead (the cathode) of the LED and solder a black wire to it. Solder the red wire to one of the out pins on the potentiometer and solder the black wire to the other outer pin of the potentiometer. This is how we will distribute power. The red wire will eventually be connected to 5V positive and the black one will have a connection with ground.
Next you need to bolt the audio jack on the inside of the controller to the hole you drilled in the front of the project box. The nice thing about this audio jack is it is easily mounted.
The audio jack and cable is able to carry 3 different signals signals across it. We will be using 5V, GND, and an analog pin for the potentiometer. There are more than 3 pins on the audio jack however. I used my multimeter to test the continuity when I plugged 2 together using an audio cable to see which pins were the ones to use. You can do this too if you would like. You can see in one of the photos which pins the potentiometer is connected to. I then soldered 3 color coded wires in place on the audio jack. You can see the pictures to see how you should do it. The black wire is GND, the red wire is 5V, and the green wire will be our analog out from the potentiometer.
(I found this next part to be easiest if you unbolt the potentiometer from the top of the project box) Finally solder the black wire from the audio jack to the outer pin of the potentiometer that you soldered the black wire from the LED onto. This will distribute GND. Solder the red wire from the audio jack to the outer pin of the potentiometer that you soldered the red wire from the LED onto. This will distribute 5V. Then solder the green wire to the center pin of the potentiometer. This is the analog out of the potentiometer.
Bolt the potentiometer back onto the top of the project box if you have not already. Screw the 4 screws of the project box on, securing the lid. Lastly, place the knob on the potentiometer so that the notch on the knob is perpendicular to the front of the box when the potentiometer is centered.
The final thing to do if you want is to check to see if you did it right and the LED lights up when you apply power. I did this by plugging in an audio cable and the other audio jack and then connecting power to the correct pins on the audio jack.
Step 4: Make the Cabinet
Now comes the time to start working with some wood. I am not the best at describing the hardware needed for stuff like this, so bear with me. From this point is is basically a choice of how you want it to look. So I should not really tell you how to build your box, but I will tell you how I built mine.
My basic concept was just something big enough to fit the screen and electronics. I decided it would be nice to have the Arduino and batteries on the outside so I could easily program and change batteries. So I left a ledge on the outside of the box for these items.
The bottom is made with 2 5.5" wide strips of hard wood that are .25" in thickness. The sides are the same type of wood. These pieces of wood are 1.5" wide and 7/16" thick. So nothing complicated, just make a box using glue, nails, and a hammer. There are some holes in the box that I will explain in the next step.
Then you will need to make a matching door. I used the same wood that was on the sides of my box and brackets to form the door. A piece of acrylic was then glued on the back using hot glue. Finally you need to attach the door using some hinges.
You should be able to find this stuff at a major hardware store.
Step 5: The Final Mounting & Wiring
We need to drill some more holes. The problem we face now is that we need to bolt the power switch and other audio jacks onto the box, but the wood is too thick and it will not bolt through. The solution is cut small pieces of acrylic, drill a hole in it, bolt the items to that and then glue the assembly on the inside of the box behind the hole. Look at the pictures to see what I am talking about.
So 3 holes have to be drilled. I made 5/8" holes. That is 1 hole in the middle of the front, left, and right side. The audio jacks go on the sides and the power switch goes on the front. Use my acrylic trick for attaching them. The black color you see behind the acrylic are pieces of construction paper I fitted in between the acrylic and the power switch/ audio jack that was being bolted on. I did this for aesthetics when viewed from the outside.
Next drill a small hole above the platform on the outside so wires can be run to and from the Arduino, battery pack, and electronics inside.
You can also drill a small hole on the platform outside the box to bolt the Arduino down. I then glued the battery holder to the right of it.
Now the final wiring can begin. You need to wire the audio jacks the same way they were wired in the controller. Connecting 5V, GND, and an analog input. I wired the left side to analog 0 and the right side to analog 1 of the Arduino.
Speaking of power, you can go ahead and distribute power to everything. Wire all the GNDs together and the 5V together on the breakout boards. I used a piece of perf board to do a little power distribution. Wire the switch up too so it is connected to the battery and will supply 5V, when switched, to the electronics including the Arduino.
Now comes the time to wire the few connections from the display to the Arduino. The "Din" of that top left breakout board of the display gets wired to pin 12 of the Arduino. The clock pins get wired to pin 11 and the load pins get wired to pin 10.
Step 6: Final Touches
There are some final touches I have. One is to add a buzzer for sound effects. My buzzer had pads instead of leads like the one I linked to, either way the connection should be the same. First identify which lead or pad is negative and which one is positive, they should be labeled with tiny "-" and "+" signs. Solder a wire with a male header on the end of it to the negative lead. In order to safely connect this to the Arduino, we need to connect a resistor to the positive lead. I used a 150ohm resistor which will prevent the buzzer from drawing too much current and damaging the Arduino. Solder the resistor onto the positive lead of the buzzer. Then plug the negative lead to the GND pin (next to digital pin 13) on the Arduino board and the positive lead with the resistor on it to pin 9 of the Arduino. I found that a little piece of electrical tape on the top of the buzzer makes it a bit louder.
The next thing I did was put a piece of foam, or paper (might be a better option to avoid ESD), under the screen to prop it up a bit and keep it from moving around. Finally the last thing I did was use a piece of construction paper to make a window that would show the screen, but block the other mess from view.
Step 7: The Program
The program has an array that stores the location of the ball and paddles as bytes. Each row of bytes is easily displayed because there are 8 bits in a byte and 8 LEDs per row. The library for the LED driver ICs has a function to display rows of LEDs as binary bytes, so this makes things really easy. The "pong simulator" function I wrote will bit shift the ball around the screen correctly, carry the ball over to a new matrix when needed, and deflect the ball off of the edge of the screen when needed. The ball randomly starts off at a row near the middle of the screen, at a random position and direction.
The analog values from the controllers gets mapped to a value to control where the paddles are located on the screen.
The hardest thing for me was getting the correct reaction when the ball meets the paddle. I wrote a few pages in a notebook coming up with the different scenarios and what I call "special bits" where the ball would need a different bounce off the paddle than normal. This might include bouncing off the wall or carrying over to another matrix. Some stuff I came up with I later found to be wrong or found that my other code would actually take care of it for me. There might still be a bug or two that I have to work out, but for right now I am pretty satisfied with its performance.
There are a few different modes I programmed in. There are two 2 player modes. The difference between them is the paddle width. There is one where the paddle is 3 LEDs wide, and another where the paddle is 2 LEDs wide (this one is obviously harder to play). The game keeps track of score and the first person to 5 points wins. The last mode is a practice, 1 player mode. The player can play against a "wall" of LEDs to practice. The modes are selected at the beginning of the program, when the game is turned on or restarted, by using one of the paddles. You have 3 seconds from after turning the game on or restarting it to choose what mode to play and then the game will begin. A display bar will show you what mode you are currently selecting during the 3 seconds.
Program explanation video:
How the ball bounces off the paddle:
Step 8: Noisy Analog Inputs
A problem that I ran into was having noisy analog inputs. The values read in from the Arduino were not steady which would lead to erratic paddle movement at times.
If you experience this then you can suppress it by using 2 .1uf non-polarized capacitors. Simply put one on the inside of the console at each audio jack. Connect one lead of the capacitor to the analog out of the audio jack and the other to GND. See the picture. This should eliminate the noise.
Step 9: Out of Date Videos
Here are all of the videos that I made in between when I started and now, not including the most recent ones on the other pages of this instructable. (The further down the page, the older the videos)
I like to show these as a record of the progress even if some of the information does not apply any longer.
We have a be nice policy.
Please be positive and constructive.