Você está na página 1de 15

Arduino Project 7: Build a Retro Gamebox - APC

Home Arduino Project 7: Build a Retro Gamebox

Arduino Project 7: Build a Retro Gamebox

Tweet

by Darren Yates August 9, 2013

http://apcmag.com/arduino-project-7-build-a-retro-gamebox.htm[31/03/2014 11:12:25 AM]

Arduino Project 7: Build a Retro Gamebox - APC

Our Retro Gamebox is built into a see-through container.


The games market may well dwarf the music and movie industries combined in global revenue and new-release games offer lighting effects and texture detail that make you forget youre
in a game and not a movie. But theres always something that tugs us back to retro gaming the blocky graphics corny 8-bit sound and those golden memories.
Our Arduino microcontroller doesnt come with a video output although we showed you in the TV Weather Channel Station Project how you could hook it up to the composite video input of
your TV and display your own TV weather channel.
So for this project were combining all this knowledge and putting together our very own retro arcade games console were calling the Retro Gamebox.

What you need


Apart from the Arduino Uno board the main components youll need are the arcade-grade joystick and fire pushbutton. They look impressive but theyre not expensive. We picked up ours
from eBay the joystick for $8.79 and the pushbutton just $3.50 both including shipping.
How the single-fire pushbutton works is pretty straightforward: the button plunger operates a normally open (NO) microswitch which closes when the button is pressed. A nice extra is that
many also have an LED inside the button top.
The joystick is a little more complex it has four NO microswitches one for each compass direction which operate as you pull the central control around. Some arcade joysticks have a
mechanical locking mechanism that will lock off one axis (X or Y) so you can use it more easily; for example locking off the Y axis so the controller becomes a side-to-side type for playing
Space Invaders.
Whether youre building a full-on replica arcade gaming machine or just our little Gamebox the joystick switches do the same job: they connect to the circuit board and when activated
http://apcmag.com/arduino-project-7-build-a-retro-gamebox.htm[31/03/2014 11:12:25 AM]

Arduino Project 7: Build a Retro Gamebox - APC

cause the software to change operation based on the switch(es) pressed.


So that you can see the insides of our design more easily weve gone for a basic see-through food container. If youre really keen you could put the whole thing together into your own fullscale retro arcade machine.

Parts list
Part

Cost

Source

Arduino Uno R3

$13.20

eBay

Eight-way arcade joystick

$8.79

eBay

Arcade pushbutton

$3.50

eBay

Dupont wires

$2.55

eBay

Red RCA socket

$0.95

Jaycar

Black RCA socket

$0.95

Jaycar

900ml kitchen food container

$2

Local $2 shop

2 x 470ohm 0.5W metal resistor

$0.46

Jaycar

1 x 1kohm 0.5W metal resistor

$0.46

Jaycar

TOTAL COST

$32.86

Games
The inspiration forthis projectof ourscame from the Hackvision system developed by Nootropic Design. Its a basic cut-down custom Arduino with four direction buttons and a fire button
all built onto a single printed circuit board. You can buy it as a prebuilt device ($44) or a kit you put together yourself ($34). However since the Arduino code for a number of games
including Space Invaders Asteroid Tetris and Sudoku has been released to open source we decided a game box with existing Arduino hardware would be a worthy inclusion into our
project list.
The main problem with the Hackvision system is the lack of USB connectivity requiring you to come up with your own USB-to-TTL adapter cable to program it. By using a standard Arduino
in our Retro Gamebox changing games is as simple as plugging the Gamebox into your PCs USB port and compiling the new Arduino sketch.

How it works
Our Retro Gamebox is surprisingly simple when it comes to hardware: five switches three resistors a couple of RCA sockets and thats about it. Well its a little more complicated than that
but when you boil it down thats all there is from an electronics viewpoint.

How the arcade joystick works


Four of the five switches belong to the arcade joystick. Mechanically an arcade joystick is just a centre bolt that pushes the actuators of four microswitches wrapped around the outside.
Each switch has two connectors: the contacts are the NO type that close when you move the joystick and actuate the switch. The trick with arcade joysticks is they operate the opposite
http://apcmag.com/arduino-project-7-build-a-retro-gamebox.htm[31/03/2014 11:12:25 AM]

Arduino Project 7: Build a Retro Gamebox - APC

switch to the direction of movement. So pushing the bar up activates the bottom switch; pushing it left operates the right switch and so on.

Arcade-grade controllers use four microswitches around a central control lever.


Electrically the switches are used to effectively create an interrupt pulse within the Arduino and cause it to perform a function based on which switch is pressed; for example when we want
our rocket ship to move in a certain direction.
In the Gamebox the digital inputs these switches are wired to are set to activate when the switch pulls that input to ground (the 0V rail). That means we can join one connector of each
microswitch together and wire it to ground creating whats called a common ground. This allows us to use just five wires from the joystick to the Arduino (one for each switch and the
common ground) instead of eight (two for each switch).

How the fire button works


The fire button works slightly differently it has just the one switch but two modes of operation. The switch has three connectors: a common connector plus one thats NO and one thats
normally closed (NC). With the switch resting the common pin is electrically connected to the NC pin. When you press the switch that common pin then connects to the NO pin and
disconnects from the NC pin.
The switch weve used here also has a built-in LED and current-limiting resistor. What weve done is hook up the anode side of the LED to the Arduinos 5V pin and the cathode side to the
pin that connects the switch to the Arduino (D10). The result is that the LED lights up whenever the fire button is pressed. Combine that with the blue power LED on the Arduino board and
you get a neat little light show.

http://apcmag.com/arduino-project-7-build-a-retro-gamebox.htm[31/03/2014 11:12:25 AM]

Arduino Project 7: Build a Retro Gamebox - APC

A good-sized fire button is a must-have for any games console!

Video/audio output
Thanks to some impressive coding from Myles Metzler and others the video and audio output that connects to your TV requires only three resistors and one of those is optional. We wont
cover how it works here but briefly composite video requires two electronic signals: the analogue video data plus the synchronisation pulses that tell the telly where the data is meant to be
on the screen. Two resistors are all thats required to combine the signals into one composite video output with the correct voltage ratios your TV will understand.

http://apcmag.com/arduino-project-7-build-a-retro-gamebox.htm[31/03/2014 11:12:25 AM]

Arduino Project 7: Build a Retro Gamebox - APC

The Gamebox features composite video out and 8-bit sound via its two RCA ports.
The audio output is really simple. The Arduino creates genuine 8-bit pulse-width modulated (PWM) sounds straight out of pin D11. Weve added a simple 470ohm current-limiting resistor
to ensure that output pin doesnt blow up if its accidently grounded. That output goes directly to your TVs audio input and gets blasted out the speakers.

No power switch required


Once youve programmed the Arduino with your choice of game itll launch it straight away. High scores are saved in the Arduinos small EEPROM memory so theyre saved even when
the power goes off. Weve not bothered with a power switch although you could integrate one into the build if you wish.

Putting it together
You can put the Retro Gamebox into any container you want so weve chosen a food container for its low cost and transparency. Full-size arcade games are impressive but we wanted you
to see whats going on inside and hopefully give you the idea that its not that complicated.

Using a food container


Weve used a 900mL food container from the local $2 shop and if you follow this route you need to take care when drilling into plastic. First set your drill speed to slow otherwise youll tear
the plastic to shreds. Second dont push too hard against the plastic to get the drill bit to bite otherwise youll split the plastic. Dont use cheap takeaway containers but a sturdy
microwaveable type. You could also use a Jaycar jiffy box although we like the see-through look. The other thing wed do differently next time is mount the RCA sockets towards the edge
of the container where the plastic is a little stronger (itll handle connecting and removing cables much more easily).

Mounting the components


Weve used standard M4 machine screws on the joystick with washers on either side of the plastic lid (one under the bolt head another before the nut). You can pick these up from any
hardware store. We ended up using a tapered reamer to size the hole for the joystick rod. However the fire button requires a sizeable 24mm hole for the centre shaft. If you dont have a
hole saw the easiest way is to pick your centre point and measure 10mm out to eight points around in the circle. You then drill pilot holes at each point and expand them out using a 3mm
drill bit. You then snip around the outer perimeter of the plastic joining those holes with a pair of side cutters (food container plastic is soft enough for this). After that youll find you can just
push out the centre piece leaving a 24mm hole you can push the fire button shaft through.

http://apcmag.com/arduino-project-7-build-a-retro-gamebox.htm[31/03/2014 11:12:25 AM]

Arduino Project 7: Build a Retro Gamebox - APC

Place washers directly against the plastic so you dont split it.
The fire button itself comes apart grab hold of the microswitch bottom section twist and pull it to unlock. Thatll give you the top shaft section which you can feed through your case and
anchor with the large plastic collar nut. There are different types of arcade pushbutton switches so your mileage may vary.
We raised the Arduino board off the bottom of the container using 5mm spacers (Jaycar) and 15mm M3 bolts (Bunnings) which fit into the Arduinos four mounting holes. Dont forget the
washers on either side of the plastic before you add in those spacers. Using a see-through container makes it easy to mark out the mounting hole positions with a Sharpie before you drill.
Finally dont forget the holes for the DC power socket and the USB port.

Wiring up the components


Our build method requires no direct soldering to the Arduino board. Instead we used Dupont male wires cutting off one end soldering it into position and pushing the pin on the other end
into the appropriate header hole on the Arduino board. The Arduino header sockets grab Dupont pins pretty well so you shouldnt have to worry about them falling out unless you start
drop-kicking the Gamebox around. We also used a small amount of standard hook-up wire to connect the common ground on the joystick and the fire button LED to the fire buttons NO
contact.

http://apcmag.com/arduino-project-7-build-a-retro-gamebox.htm[31/03/2014 11:12:25 AM]

Arduino Project 7: Build a Retro Gamebox - APC

You can use proper spade lugs to solder the joystick and fire button switches or solder direct as we did.
Just make sure you dont wire everything so short that you cant take the lid off easily. Really how you build it is up to you as long as you follow the circuit diagram you can build it on a
lump of wood if you like and it should still do the job.

http://apcmag.com/arduino-project-7-build-a-retro-gamebox.htm[31/03/2014 11:12:25 AM]

Arduino Project 7: Build a Retro Gamebox - APC

The Retro Gameboxs circuit diagram is pretty simple.

Programming it & hooking it up


Although these classic games were originally ported to work on the Nootropic Design Hackvision board weve designed the Gamebox so theyll happily work here too. Provided youve
followed the circuit diagram when building your Gamebox all you have to do is download the required files and libraries for each game onto your PC compile the Arduino sketch and upload
it to your Gamebox no game code needs to be harmed in the making of this project.
To make it easier weve put each game together with a package of libraries your Arduino IDE will need in order to compile it. Theyre based around Myles Metzlers excellent Arduino
TVout library Nootropic Designs controller library which handles the joystick and fire button plus other libraries where appropriate.
For all games other than Space Invaders just copy the contents of the libraries folder across to your Arduino IDEs libraries folder and overwrite any existing files. With Space Invaders you
especially need to delete any existing TVout folder and replace it with the one bundled with the Space Invaders code. You then need to compile the sketch code and program your Arduino.
The Space Invaders port was written for an older version of TVout and wont work with the current release thats why you need to delete any previous version and use the specific
version including the ZIP file.
We used the latest version 1.0.3 of the Arduino IDE available from arduino.cc/en/main/software.

Hooking it up to your TV
This is the fun bit. Use a standard stereo pair RCA cable and connect one side into the Retro Gamebox and the other end into the composite video and audio inputs of your TV or monitor.
Go with a 3m or 5m cable to give you enough length that youre not sitting on top of the telly to play. Powering the Gamebox youll need a 9VDC or 12VDC power brick with the centre pin
positive and the other ring negative. The Arduino pulls no more than 50mA so just about any correct voltage/polarity power brick should work. You could also power the Gamebox with a
USB power adapter from your smartphone or tablet and plug a USB cable into the Arduino weve tested this and it works just fine.

http://apcmag.com/arduino-project-7-build-a-retro-gamebox.htm[31/03/2014 11:12:25 AM]

Arduino Project 7: Build a Retro Gamebox - APC

Weve soldered the output resistors directly to the RCA sockets. Its not ideal but its quick.

PAL or NTSC?
By default Gamebox is set to deliver US-based NTSC-standard video. Thats not a problem for modern TVs as they all handle NTSC and Australias PAL video system but if youre
planning to run this on an older CRT TV thats PAL only add a wire from D12 to ground to tell the Arduino you want PAL video output. Apparently this also speeds up gameplay for some
reason we havent figured out yet; most likely due to the change in video frame rate from 60Hz to 50Hz. Arduino only does monochrome video so dont expect to see flashy colours.
Turn the TV volume down a bit before you start as the Arduinos audio output can be a maximum 5V peak to peak and dont forget to select the appropriate TV input to see the video.
To reset the Gamebox just pull the power out and plug it back in again. You could add in a small pushbutton switch that pulls the RESET pin to ground but thats entirely optional.

Writing your own games


Once youve had a play for a while why not have a bash at writing your own games? If youre thinking about gaming a simple setup like the Retro Gamebox will help you understand what
makes good gameplay without getting sidetracked with producing eye-popping graphics.
Peer through the Arduino sketches for each game to glean ideas and head to the Nootropic Design web site for more details. Dont forget the Arduino web site for more on coding the
Arduino.

http://apcmag.com/arduino-project-7-build-a-retro-gamebox.htm[31/03/2014 11:12:25 AM]

Arduino Project 7: Build a Retro Gamebox - APC

The classic Space Invaders still rocks!

Hackvision Arduino game sketches


You can find the original games available at nootropicdesign.com/hackvision/. To make it easier weve put together each game as a separate ZIP pack with all the required libraries
included. You can grab them from theAPC web site at apcmag.com/arduino.htmunder Project 07. Note: Make sure you read through Programming it & hooking it up section of this article
for special information on uploading Space Invaders to your Retro Gamebox.
For a list of Arduino projects weve created (more to come) go to Arduino Projects APC Master Class Series.

Search Site

http://apcmag.com/arduino-project-7-build-a-retro-gamebox.htm[31/03/2014 11:12:25 AM]

Search

Arduino Project 7: Build a Retro Gamebox - APC

Follow us

http://apcmag.com/arduino-project-7-build-a-retro-gamebox.htm[31/03/2014 11:12:25 AM]

Arduino Project 7: Build a Retro Gamebox - APC

Recent Comments
Darren Yates on Arduino Masterclass
Part 4: Build a mini robot
Darren Yates on Arduino Project 5:
Digital audio player
HarryDGrif on Best iPhone and iPad
apps, February 2014
SicaBixby on The best PC gaming
accessories: 8 gaming keyboards
reviewed and rated
Raquib Buksh on Arduino Masterclass
Part 4: Build a mini robot

About APC Magazine


Whats inside APC this month
APC team
Advertise with us
Contact Us

Magazine Resource
APC Tutorial Files
Arduino Source Codes

http://apcmag.com/arduino-project-7-build-a-retro-gamebox.htm[31/03/2014 11:12:25 AM]

Arduino Project 7: Build a Retro Gamebox - APC

Tweets by @APCmag

This week's Poll


How long since you last bought a PC?

I upgraded this week!


The past few months
My PC is around a year old now
Really, it's been over a year? Where
did that time go?
My 386 is still going strong...

Vote
View Results Polldaddy.com

http://apcmag.com/arduino-project-7-build-a-retro-gamebox.htm[31/03/2014 11:12:25 AM]

Arduino Project 7: Build a Retro Gamebox - APC

Top

Future is AOP & PPA Digital Publisher of the Year and BMA Media Company of the Year.
This siteis part of Future plc, an international media group and leading digital publisher. We produce content across five core areas:

About Future

Jobs

PR

Advertising

Digital Future

Privacy Policy

Cookies Policy

Terms & Conditions

Subscriptions

Investor Relations

Contact Future

Future Publishing (Overseas) Limited, Beauford Court, 30 Monmouth Street, Bath BA1 2BW. All rights reserved. England and Wales company registration number 06202940. Australian Office: Suite 3, Level 10, 100 Walker Street, North Sydney, NSW
2060 T: +61 2 9955 2677

http://apcmag.com/arduino-project-7-build-a-retro-gamebox.htm[31/03/2014 11:12:25 AM]

Você também pode gostar