Introduction: Christmas Card With Inbuilt Retro Video Game for Under $10
Hello all and welcome to my second Christmas related project.
Have you ever received a really boring Christmas card? Have you ever sat there and thought to yourself "If only there were a little video game on this card that I could play..." Well ponder no more because that card is here!
This instructable will show you how to make your very own retro video game Christmas card which can be made for less than $10. All you need is some time, some soldering know how and roughly $10 in your wallet.
Please view this youtube video to get the main idea of this project:
There are essentially two main parts to building this project.
1. Soldering all the parts to the vero board (experimenters board)
2. Making the card itself (this is where you can get creative)
The game is titled "Santas Scramble" and is played within 64 pixels on an 8x8 LED matrix display. You play santa (a red dot) who is frantically flying around the world in order to get all of the presents delivered to the children in time for Christmas, the only problem is that he has flown into a dangerous maze. Your job is to steer santa up and down the screen in order to avoid the oncoming obsticles. Be careful, the further you get through the game, the faster it gets. If you crash then it is - GAME OVER -
There are two different designs below and I must apologise for my lack of arts and crafts ability. My strong point is the electronics side of things...
Anyway - lets get started shall we!
Step 1: Gathering Together the Required Parts.
As stated in the introduction, there are essentially two main parts to this instructable.
1. Building the electronic circuit
2. Constructing the card
Here is what you will need for the electronic circuit:
- 1 x pic 16f648a microcontroller
- 1 x 7442 (1 of 10 decoder IC)
- 2 x cr2032 batteries
- 2 x cr2032 battery holders
- 1 x 32 hole by 23 hole piece of veroboard / strip board
- 2 x push buttons
- 1 x 8x8 bi-colour LED matrix display
- 9 x 150 ohm resistors 1/4 watt
- 2 x 10k ohm resistors 1/4 watt
- length of enamel wire (the really thin wire with a coating of enamel for insulation)
- shorter length of single core wire
- Soldering iron
- scalpel (or sharp knife)
- solder wick (optional but handy if you make a soldering error)
- Flux (optional but helps with soldering)
- pic microcontroller programmer
here is what you will need for the card:
- paper (all sorts of colours to make it more interesting)
- thin cardboard
- thick corrugated cardboard (the cardboard that packing boxes are made from)
- glue stick
- double sided tape
- sticky tape
- scalpel (or sharp knife)
- what ever else you can think of to make a nice looking card
- Pay a visit to sure electronics webstore where you can buy a lot of 10 Led matrix displays for around $8.60 this makes them 86c each!
- ebay is a great place to buy electronic components. Make sure you do a worldwide search since postage is normally quite cheap for lightweight components.
- Head on over to microchip.com and sign up to their online store. Then you can buy parts directly from them. For example here in Australia it would cost me $10 for a 16f648a microcontroller. But if I buy them from microchip they are just over $1.
- You can also request free samples from microchip. I think you can get about 6 free samples a month. This has been very handy for me in experimenting with different chips.
Step 2: Program the Microcontroller
At this stage, you will want to program your microcontroller with the santas scramble game hex file. There are many different programmers out there so I will not be able to explain the exact process.
You can download the hex file from the bottom of this page.
Simply open the hex file in your programming software and burn it to the microcontroller. Then you are ready to commence construction!
Step 3: Cut the Board to Size.
The veroboard (strip board) will need to be cut to 32 holes by 23 holes.
Please see the photo below for reference.
Note that the tracks are aligned vertically.
Step 4: Soldering All the Components Onto the Board.
I like to solder in everything in one big hit. Then from there we can cut the necessary tracks and solder our enamel wire to form a complete circuit. (which will be covered in the following two steps)
But for now, lets just solder in the components. Have a look at the photo's below for the location of each component. One item to note is the 8x8 LED matrix. You must insert it the correct way otherwise it won't work. See the third photo for a close up.
Also you should note that both the microcontroller and the 7442 IC are mounted such that pin 1 is to the bottom left.
You can see both the top (component side) and the reverse (solder side) of the board.
Step 5: Cutting the Veroboard Tracks
As it is, we have shorted out all of our IC's legs from top to bottom as well as the resistors, buttons and LED matrix. We need to cut a whole heap of tracks in order to make sure that we are not shorting out any of the components.
Please refer to the photo's below for a look at where to cut the tracks. The first photo shows where the tracks have been cut by red ovals. The second photo is exactly the same just with the ovals removed for clarity.
Step 6: Study the Schematic.
You can download the schematic below. Have a look at it since you will need to match the circuit you are building, to this schematic.
It is very likely that some of the components that you will be using will not match my components exactly (E.G the led matrix and push buttons) so it is important that you study the schematic diagram and as long as you wire together yours accordingly, you will be just fine!
Here is a direct link to the original full size schematic:
I have also included the pinouts for the pic16f648a microcontroller and the 7442 decoder IC.
Power is provided by two CR2032 batteries connected in series (I.E the -ve of one battery is connected to the +ve of the second thus providing you with 6volts to power the circuit. This 6volts connects to the GND and VCC connections indicated in the schematic provided.
Step 7: Completing the Circuit With Enamel Wire.
Enamel coated wire is fantastic for veroboard projects.
The enamel coated wire comes in many guages, but I prefer to use .25mm thick enamel wire. This can be bought in little reels at most electronic stores or online.
Even though the wire looks like it is not coated (insulated) it actually is - with a very fine varnish so it is fine for the wires to touch each other (I.E. they wont short each other out.) Before you can solder these wires on though - you must first strip the ends. The easiest way to do this is to put a blob of solder on your soldering iron and then place the end of the wire into the molten blob, this will melt off the tip of the enamel wire which will give you a 'stripped' end ready to be soldered to the board.
The first photo shows strands of wire ready to be 'stripped' the second photo shows those same wires with the ends removed of enamel. The third photo shows the completed board. With all connections made.
you will also notice that I have used thicker wire with the green insulation. These are the power connections.
Here is a description of the five green wires:
- 1st battery +ve to 2nd battery -ve
- 1st battery -ve to microcontroller GND and 7442 GND
- 2nd battery +ve to microcontroller VCC and 7442 VCC
Step 8: Circuit Testing.
Once your circuit is built you will obviously want to test it.
Pressing either of the buttons will turn the screen on and the game will start to play. If you then press the down button, you player should move down. If you press the up button, your player should move up.
If you hit a wall the game should stop and present you with the level number that you made it to.
If you complete the game, then you should be presented with a smiley face.
Pressing either of the buttons on any end game screen should take you back to the start of the game.
If you dont press any buttons for approx 30 seconds, the game should go into standby mode and the screen will turn off.
* PLEASE NOTE * upon further testing, standby mode draws quite a bit of current and as such your batteries will die in a matter of days EVEN WHEN NOt BEING PLAYED. I highly recommend that you add an ON / OFF switch to your circuit to fix this problem.
Step 9: Cutting the Thick Cardboard to Size.
Now as stated in the introduction, arts and crafts is certainly not one of my strong points. So this is where you guys can get creative! The main thing to have a look at in these next steps is the housing for the circuit board itself. All the extra decorations I will leave to you to let your imagination run wild!
1. First off you will need some thick corrugated cardboard - most packing / packaging boxes will use this type of cardboard. (see the first photo below for reference)
Cut out two squares with sides of 12cm each. (see second photo)
Step 10: Cut Out a Space for the Circuit Board.
Place your completed circuit board on top of one of your cardboard squares. Line it up in the centre and cut around it with a scalpel or stanley knife. (see first photo)
Repeat this step for your second piece of cardboard.
one both of them are done, place one ontop of the other and tape together. (see second photo)
Step 11: Install the Backing for the Circuit Board Housing.
Now we don't want the circuit board to fall out, so cut yourself a 12cm square piece of thin cardboard and tape it to the rear of your circuit board housing.
Step 12: Install the Circuit Board and Fill the Gaps.
Now with the back plate on, you can insert your circuit board into the housing.
You will notice that some components (namely the IC's and resistors) are seated lower than the other components. We need to fill in this space with some more thick cardboard to try and level everything out. (see the first photo)
This step just involves a little bit of manipulation in order to construct a piece that will fill the space.
(see the second photo for what my gap filler looks like)
Now basically everything is level with the top of the circuit board housing. (which means it will all be nice and flat when we place our decoration paper on top of it all.)
Once constructed, tape it all to hold it in place (see third photo)
The final step to this phase is to cut two pieces of thin cardboard to cover the batteries. Once cut - tape them in place (refer to the fourth photo)
Step 13: Start to Make It Look Pretty...
Now that the housing is complete you will want to make it look nice by adding decoration.
This is where you can start to get a little creative yourself (or rather - more creative than me...) All I did at this point was to use a whole heap of double sided tape and stick down some Christmas wrapping paper. (see the first photo for the double sided tape BEFORE the backing has been removed)
The second photo shows the completed package with the screen square cut out.
The third photo shows the rear of the card.
you may have noticed that there a re no holes for the push buttons - that's okay because you can still press them even with paper ontop - nifty huh?
Step 14: Stick Down Your Button Locators.
I cut two little stars from a Christmas card for my button locators.
I just stuck them down on top of where the two buttons are.
Step 15: Construct and Attach the Card Flap.
With the 'main' part of the card built, it is now time to construct the front cover card flap.
You will again need a 12cm square piece of thin cardboard.
Decorate it however you please (I used some more wrapping paper to decorate mine) The first photo shows the 12cm square piece of cardboard and also a 12cm square piece of Christmas wrapping paper.
Once you have it looking just as you want, use two lengths of sticky tape one on the outside of the card and one on the inside to hold the flap in place.
the second photo shows the completed flap in place.
Step 16: Final Testing and Thoughts...
Just as with the previous test, if you press any of the two buttons, the game should turn on.
Pressing the up and down buttons should make you move up and down accordingly.
If you don't press any buttons for approximately 30 seconds, the game should go into standby mode.
I really could have made this project better in a number of ways.
1. I should have included an ON / OFF switch. upon further testing, the standby mode actually draws quite a bit of current still and therefor the batteries will die in a couple of days even if you don't play it... So a power switch would fix this problem.
2. I need to work on my arts and crafts. Mine certainly could look a whole lot prettier!
3. Make the batteries more accessible for ease of replacement.
4. Maybe even replace the coin cell batteries with a mobile phone battery and include the charging circuitry so that the card could be recharged using USB?
Step 17: Description of How the Circuit Works.
The 8x8 LED matrix display's are (believe it or not) connected in a matrix. This means that you don't just have 2 connections for each led (of which there are 64 LED's) instead, the LED's are connected in such a way that we can light up every LED in the matrix and to do this, we only require 16 connections (rather than 128 doing it individually)
You will notice the image on the left has 64 LED's connected in an 8x8 LED matrix. There are 8 Columns where the cathodes are all connected together and also 8 Rows where the anodes are all connected together. The image on the right will be used to demonstrate how we get the matrix to do what we want.
(REFER TO PHOTO 1)
Let's start out nice and simple. What if we wanted to turn on just the top right LED. Well. we would need to ground the right most cathode and then connect the top Anode to our power supply (+5v) through a resistor, just like this next picture:
(REFER TO PHOTO 2)
You may also have guessed that if we connect +5v to the top row of anodes then EVERY anode up the top will have +5v connected to it. The reason that only the top right LED turns on is because we have only connected ground to the right most column of cathodes. We need the combination of +5v AND ground in order to complete the circuit to turn on whatever LED or LED's that we want.
What about if we wanted to turn on an entire Column of LED's? We'll you would connect your matrix as follows:
(REFER TO PHOTO 3)
Or perhaps you want to turn on an entire row?
(REFER TO PHOTO 4)
I will be using this next circuit to explain things a little further.
(REFER TO PHOTO 5)
To help us with scanning the display, we use a 7442 1 of 10 decoder.
(REFER TO PHOTO 6)
The 7442 is a 16 pin chip, of course it has a +5v connection and ground in order to power it up. It also has four inputs namely A, B, C and D. lastly, it has 10 outputs - 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. It is quite a simple chip to work with. The outputs will vary depending on what combination of 1's and 0's are on the inputs. All outputs of this chip will be a logic high EXCEPT for one. That one will depend on the input. Here is a chart showing you what the output will be for all combinations of inputs
(REFER TO PHOTO 7)
having a look at the 7442 output, we can make any one of the outputs low (or pretty much connect it to ground) by giving a certain combination on the input. If we wanted output 0 to be low then we would input 0000 OR if we wanted output 6 to be low then we would input 0110 etc...
We only require 8 (of the 10) outputs from this chip therefor we use these 8 combinations on the input:
This means that we don't need to use the fourth input line (D) so that is why I have connected it straight to ground and only the first three inputs (A, B and C) are connected to the microcontroller so we can control them. So this means that we will have any one of these eight combinations on the inputs:
So hopefully you can see that by using this chip, we can 'Activate' one column of Cathodes at a time by connecting one column at a time to ground (logic 0) and to do this it only required 3 I/O lines from the microcontroller - whereas without the 7442, we would have required 8 I/O lines and we only have seven to spare (because PORTB is used for the anodes and PORTA pin 5 cannot be an output)
So now we are working towards drawing a picture on the screen. Here is what we want to draw:
(REFER TO PHOTO 8)
Now you may very well be asking "That's a pretty picture, BUT how do we draw a picture with all of those LED's lit up at once if we can only 'activate' one column at a time?"
We'll I am glad that you asked that question! there is a little bit of a trick to it.
What you see on the 8x8 matrix is a face. BUT not all columns are on at the same time - infact only one column is drawn at any one time but we 'scan' through the columns so fast, that to the human eye it just looks like one steady image.
If we were to slow down how fast we scan through the display, you would see something like the next photo.
(REFER TO PHOTO 9)
You will notice that we activate a column, then place eight bits of data on the data bus and it displays that data on just that one column. Then we move to the next column in line and then place a different eight bits of data on the data bus for that column. We keep doing this until we get to the end. That is one complete frame.
If we were to do this alot faster then our brains would perceive this as one steady image. Similar to how your TV or computer monitor works.
I hope this discription helps!
First Prize in the
Homemade Holidays Contest