One of my favorite hobbies is to re-create the classic game of Pong whenever I learn a new langauge. I had realized that I hadn't yet made pong with Discrete Hardware or Arduino yet. So I figured before tackling the pure discrete hardware version, I could first create it with my Arduino. To do this, I utilized a very classic Dot-Matrix Display. This was a technology that I had never used before, but assumed that since it was frequently used all over the world, it must be fairly simple to work with.
Hopefully you watched the video and could see that the end product looks quite nice! There are sound effects if you happened to listen with sound off. Although the wiring is rather spread out I am proud of the wiring job that I did on this project. I made choices to try and accomodate the NPN Transistors I needed to use to be able to drive the two Dot Matrix displays. It is for this same reason that I seperated the shift registers out the way they are. I put the Column shift register close to the dot matrix display so that I could wire it up without its wires actually inconviencing the rest of the wiring that had to be done.
As I mentioned the majority of the wiring decisions were made to try and accomadate the NPN transistors that had to be used to drive the dot matrix displays. Transistors are something which I have not worked with often so this was a great chance for me to figure them out. The way that a Dot Matrix display works is connecting the LEDs inside of it to power and to ground. There isn't any discrete logic or micro-processor inside of them. This means that when turning on LEDs, you provide Power to entire columns, and ground to entire rows. So if you wanted to turn on Led[1,1], that is row 1 column 1, you would need to provide power to Column 1, and ground all of Row 1. If you were just utilizing outputs from the shift register(or arduino directly), you would not be able to complete the circuit for the LED, and would be unable to turn it on. The NPN transistors allow me to Open and Close the circuit, that is to say, to disconnect the Dot Matrix Led rows from ground, and reconnect them.
Well all of that is fine and dandy, so once I had the transistors set up I had to figure out how to actually create a "screen" from the display. Well it is important to remember that you turn on whole Rows and Columns when you complete the circuit. This means that having certain LEDs on and certain LEDs off can be quite difficult. For example you want to turn on LED[1,1], [1,2], and [2,2]. To do this you would complete the circuit for Row 1, Row 2, Column 1, and Column 2. Except this would also turn on LED[2,1]! To get around this, I decided to create a Control circuit, and flash the state of my game by only turning on a single Pixel at a time.
You can view the code on github.
If you took a look at the code, you can see that I used my control circuit via shifting in only one LED at a time, and then shift it out and show the next one. Utilizing this method, and doing it very quickly(This is basically PWM), I am able to control each LED individually. But this is the reason that the LEDs get darker when their are more of them on during the main Game State. I optimized this for Score showing to try and maximise brightness and returned to the classic way of turning on whole rows and columns.
I have shown the basic wiring from the shift registers to the Dot Matrix display. I want to note the seperate Serial Data line for the two grops of Shift Registers. This is to have more control over what is on and off without having to clear out entire registers to enable more data. Many implementions of shift registers in arduino examples tend to use 'shiftOut' and then shift entire bits. I believe this obsfucates what is actually happening, and also limits control over the next step of the arduino. I additionally turn off Output Enable to hide any out flicker of the bit leaving the registers. As to provide detail of how to wire the dot matrix display(it changes on the type you have) I did not include the rest of the shift register wiring, or the buttons, as that can change for whomever is implementing pong! If I did it again I would most certainly not use buttons, and opt for something more intuitive. You can note My shift Registers are upside down in the schematic, again this is to align the outputs to the correct places to make the wiring easier and more clear. In my actual circuit, the Row Registers and Column Registers are placed with opposite alignments for the same reason. Although I regret placing the Column register upside down as it created un-necassary wire overlap on the chip.
This was a fantasticly fun project and one of my most Polished(ironicly because it is a hardware project). The sound helps make the game complete and the game is satisfying to play as well. The next step is for me to build the game with Discrete Logic!