Monday, October 27, 2008

Using the InputShield to make an Open Source Game boy

Ok, so ever since middle school I've wanted to make one of these... but I only now have enough know-how and support to make it, ... an Open Source game boy :) Actually, it's a little smaller than a game boy, but it's 1000% cooler (in my opinion) because it uses an Arduino as the "core", and a few modules and shields that already exist.

Here are a couple other pictures of the GamePack (it's like the GadgetPack, except in the free spot, I put the InputShield)... makes me wish I had a "hand model" like in Zoolander - ha:

Then I took a photo a little further back, and it had the cheapo home depot construction light that my friend uses to light up stuff (with a fluorescent bulb) in the picture, and it kind of looked like an alien was looking down at it, so I kept it:

I took this video as soon as I had everything up and running, and it's running the source code that's pasted at the bottom of the post...

Here's another video of pretty much the same thing...

I don't know if I really like the lighting in the videos, but I'm not a professional video taker, so I'll have to read up some books at Barnes and Noble around the corner and try to figure it out. I'm still using the same Aiptek mini HD recorder, and not some fancy equipment.

Anyway, here's the source code that runs on the Arduino:


#define RXPIN 3
#define TXPIN 2

AFSoftSerial mySerial = AFSoftSerial(RXPIN, TXPIN);

unsigned char x=0;

void setup()

/* Sync up by waiting for character */
while( != 'U');

void loop()
/* The first analog pin sent */

/* send 6 Analog Pin values */
while (x <>





void serial_sendDigital(unsigned char digitalPin)

if ( (digitalPin <> 13) )

mySerial.print((unsigned char)digitalRead(digitalPin));


void serial_sendAnalog(unsigned char analogPin)
unsigned char lowByte, highByte;
unsigned int val;

/* Pin number range check */
if (analogPin > 6)

/* Get the value */
val = analogRead(analogPin);

/* Separate the value into 2 bytes */
lowByte = (unsigned char)val;
highByte = (unsigned char)(val >> 8);

/* Send the high byte */

/* Write delay */

/* Send the low byte */

/* Write delay */

And here's the source code that goes on the TouchShield:

COLOR green = { 0, 255, 0 };
COLOR blue = {0,0,255};
COLOR yellow = {255,255,0};
COLOR black = {0,0,0};
COLOR white = {255,255,255};
COLOR grey = {0x77,0x77,0x77};
COLOR red = {255,0,0};

POINT my_point;

unsigned int analogValues[6];
unsigned char digitalValues[10];

LCD_RECT digitalRect = { 118, 15, 127, 115 };
LCD_RECT analogRect = {0, 60, 32, 121 };

unsigned char x;

void setup()


/* The sync character */

unsigned int oldx, oldy, newx, newy;
int erasemode = 2;
int pencolor = 1;

void loop()
//digitalValues[0] - digital pin 4, button A MODEA
//digitalValues[1] - digital pin 5, button B MODEA
//digitalValues[4] - digital pin 8, button A MODEB
//digitalValues[5] - digital pin 9, button B MODEB
//analogValues[5] - joystick y, MODEA
//analogValues[4] - joystick x, MODEA
//analogValues[3] - joystick y, MODEB
//analogValues[2] - joystick x, MODEB

//Read analog values

analogValues[0] = ( <

analogValues[1] = ( <

analogValues[2] = ( <

analogValues[3] = ( <

analogValues[4] = ( <

analogValues[5] = ( <


//Read digital values:

//Read digital values
digitalValues[0] =;
digitalValues[1] =;
digitalValues[2] =;
digitalValues[3] =;
digitalValues[4] =;
digitalValues[5] =;
digitalValues[6] =;
digitalValues[7] =;
digitalValues[8] =;
digitalValues[9] =;

if (touch_get_cursor(&my_point)) {
lcd_clearScreen( black);


if (erasemode && ((oldx != newx) (oldy != newy))) {
lcd_circle(oldx,oldy,5, black, black);
if (pencolor == 1) {
lcd_circle(newx,newy,5, blue, blue);
} else if (pencolor == 2) {
lcd_circle(newx,newy,5, green, green);
} else if (pencolor == 3) {
lcd_circle(newx,newy,5, red, red);
} else {
lcd_circle(newx,newy,5, white, white);

if (!digitalValues[0]) {
erasemode = !erasemode;

if (!digitalValues[1]) {
if (pencolor == 5) {
pencolor = 1;



Simon said...

Looks pretty cool. :)
I've wanted to do something similar for a long time, especially when I found that the PSP-style screens (with touch screen overlays) are available.

For anyone slightly more interested in writing games and slightly less interested in designing hardware, I'd recommend the XGameStation plaform - you can still solder stuff (and learn as you go) but the system is already designed for you. (They're also available from Make.)

Unknown said...

Wow, that is just totally and unbelievably cool! Wow.


Mike G. said...

you should maybe try a diffuser if you're not happy with the lighting. a diffuser would give you a softer light that isn't as harsh

noob7 said...

great tutorial.

Anonymous said...

Wow, what a great website you have here. It is nice to see actual fresh content for a change. From one webmaster to another, I congratulate you for the effort you must have put in. I will definitely recommend your website to my readers which is highly related to your theme. Keep up the great work on your website!
Check mine if you like

Unknown said...

wow cool.

Anonymous said...

I've been trying to get people to switch to FREE and open software for a while and it's articles like this that just might persuade some of them. Thanks !

Matt said...

hi jazzy jeph! thanks a lot :) actually, i definitely could not have done it without lots of help too...

Anonymous said...
This comment has been removed by a blog administrator.
Unknown said...

Great Idea. Just wondering, about how much did this cost?