Simple Handheld Gaming Device

Good day everyone.

I was following arduino project for quite some time, and now I finally decided to start planning for my own project :slight_smile: I specifically registered to create this topic!
So I would like your opinion and input regarding my idea if possible :slight_smile:

So anyway, I looked at a lot of simeple things like LED clocks, robots using servo, etc. it doesn't seem very difficult, but for me it's not really interesting either... I would like to try building simple gaming system, even if it's too difficult for starters. I think I can manage it if I have you help because I worked as programmer for several years already so this whole programming part doesn't seem difficult to me, the only difficult part is to figure out how to connect everything and what signals need to be sent :slight_smile:

So, anyway. Here's what I would like to build:

But before I have several things to decide and problems to overcome:

  1. What arduino board should I choose? I think mega is the best choise in this case.
  2. What display to choose, and how exactly can I send signal to it and display something? If you can provide link to some tutorials it will be extremely helpful!
  3. Can arduino run code from sd card or is it must only be on its flash to run...?
  4. How do I interface with SD card and what can I do with it?
  5. How can I conserve pins on buttons without using another microcontroller? Ideally I would like to include even more buttons but there are not that many pins...
  6. Can arduino produce actual sound or only buzz? (as I've seen in youtube videos)
  7. Is it even doable, this whole project? Will arduino have enough power to run games like mario at decent fps?

info: I do have a will to make it if it's possible and I don't care for money, even if it will cost me 1000$.

So, can you please help me figure out all the details to be able to actually start it?

This might give you an idea of the gaming capability of an arduino.

I must disagree
http://belogic.com/uzebox/index.asp
here's a game console made using the same microcontroller as arduino mega.

Omnipotent:
I must disagree
http://belogic.com/uzebox/index.asp
here's a game console made using the same microcontroller as arduino mega.

That isn't based on the same controller. The UNO uses an ATmega328. The Arduino Mega uses an ATmega2550. Which basically the same core with more IO.

That system is based on an ATmega644 which is clocked faster and a has dedicated chip to create NTSC video. Not exactly a fair comparison to an Arduino (Mega).

Here is what claims to be Asteroids with Arduino it has sound in the video and a link to some zip files. You will have to decide if you can use any of it.

http://www.google.com/url?sa=t&rct=j&q=arduino%20asteroids&source=web&cd=3&ved=0CDYQtwIwAg&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJ7hnglh-dEQ&ei=Xt3sTsyPMeWFsgKE0bClCQ&usg=AFQjCNF5IYSVQt4EO5lkVTGem9ac6kjo-w&cad=rja

Omnipotent:
So, anyway. Here's what I would like to build:

I believe that it is possible to do as you are wanting to do, and I have believed this for a long time (I have some posts about this in the old forum, as well as here in the new forum - look 'em up for my thoughts on it, some of which I will share here as well).

But before I have several things to decide and problems to overcome:

Omnipotent:

  1. What arduino board should I choose? I think mega is the best choise in this case.

Maybe a mega would be better, but my thoughts on the project have always leaned toward a multi ATMega328 solution, with a single "master" controlling multiple "slave" processors (one for controls/input, one for music/sound, and one for display) via I2C, SPI, or some other hardware serial (or parallel, if needed) interface. Really, I2C and/or SPI would be the better choice, as you can hang multiple things off the bus (addressable), and use few pins (this means that, in theory, you could use smaller processors - like the ATTiny - for maybe sound and the control input processors).

The thing the larger ATMega1280 or 2560 will give you is RAM and flash memory, both of which could be important to this project; so perhaps make one of those be the "master" processor, but off-load the rest to other processors on a serial bus.

Note also that the ATMega644 is a reasonable alternative (as you posted regarding the Uzebox) that, and comes in a DIP format (which could be useful for a handheld device, as well as for prototyping on a breadboard). Alternatively, there are some small footprint Mega boards out there as well (even the standard Mega is pretty small, though, IMO); ultimately, you're going to want to do a lot of "standalone" devices for this project, if you intend to actually package it in a handheld case design, I think.

Omnipotent:
2. What display to choose, and how exactly can I send signal to it and display something? If you can provide link to some tutorials it will be extremely helpful!

I would actually go for a monochrome display using the KS0108 chipset; the popular size (which fits well with the ATMega328 memory footprint) has a 128x64 pixel display (and there are a few games done on the Arduino out there which have used this display). You may or may not be able to get a "full color" display to work; such displays need more memory, and there aren't many large ones that are easy to interface with (many seem to need constant refresh signal sent, pulling from an off-board memory buffer; there are some, though, which are SPI based with on-board memory - but they tend to be tiny). Something you may want to look into, if you use a monochrome display, is a controllable RGB backlight, which could be used (potentially) to add "special effects" lighting...

Omnipotent:
3. Can arduino run code from sd card or is it must only be on its flash to run...?

No - it must be on the flash to run.

Omnipotent:
4. How do I interface with SD card and what can I do with it?

There are many methods and libraries out there to deal with SD cards and such (see here: http://arduino.cc/forum/index.php/board,66.0.html); I won't rehash them here, only to say do some more research.

In theory, you could load a sketch (well, the hex binary, actually) off an SD card - but it would require a special/custom bootloader with SD read capabilities (I don't know if one has been written or not - I think maybe one has, somewhere); I floated an idea to someone on these forums (you?) not too long back about using one Arduino reading from an SD card to flash another Arduino via a sketch modeled off the ArduinoISP sketch (though there may be pin conflict issues there between using the ICSP pins and the SPI pins - not sure, I haven't researched it).

Omnipotent:
5. How can I conserve pins on buttons without using another microcontroller? Ideally I would like to include even more buttons but there are not that many pins...

What's wrong with using more than one microcontroller? How do you think the build consoles, handheld game systems, your PC, and the like? Multiple processors are where it is at, and has been for a long, long while (in the home PC market, since 1985 with the Amiga - which allowed it unprecedented multimedia capabilities for its time, which wouldn't be matched for a long time by PCs - although technically, the Amiga wasn't "first" at it).

But - if you insist - the best way would be (as mentioned) to use an I2C or SPI bus to communicate with chips that can hang off that bus; such chips include pin expanders (for i/o), flash memory, ADCs and DACs, real-time clocks (RTC) - you name it, it's out there.

Omnipotent:
6. Can arduino produce actual sound or only buzz? (as I've seen in youtube videos)

Programmed right (ie - you need to be a "god programmer" in the "demo scene" to pull it off) you can get an ATMega equivalent to emulate a SID chip (and more), if you so desire:

http://www.linusakesson.net/scene/craft/

In this case, it was an ATMega88...check out his other demos, and check out his SID emulator (The hardware chiptune project) - aka "chiptunes" if you know that term...

Suffice to say, you can get an ATMega to make great sound (granted, doing so while doing other things, like graphics, game logic, etc - may or may not be that easy; if you want to have any hope of pulling -that- off, use timer interrupts to drive the sound output from a buffer that you feed outside the interrupt routine; really, it would be easier to simply off-load the sound to a dedicated microcontroller on a serial bus).

Omnipotent:
7. Is it even doable, this whole project? Will arduino have enough power to run games like mario at decent fps?

Mario? That's probably reaching a bit (maybe) - but things like Asteroids, PacMan, or similar "old school" style games that don't require much in the way of memory; I have no doubt that it is possible. People have already created similar "standalone" games of such nature on the aforementioned KS0108 LCD for the Arduino; heck, with the right programming and data management techniques (like those used on the Uzebox), you might even be able to create a version of Mario or other tile-scrolling game. I would suggest studying how such games from the past were created, and the techniques used, and scale those to work with the footprint of the Arduino you plan to use.

Omnipotent:
info: I do have a will to make it if it's possible and I don't care for money, even if it will cost me 1000$.

So, can you please help me figure out all the details to be able to actually start it?

I wish you all the luck and I hope to see somebody build such a system - I have long thought this would make a great project, but I've had too much on my plate to pursue such a thing. Something else to keep in mind (and something I have mentioned before in similar discussion threads) is that if you set the whole system up right, you can make this "game hardware" into something much more powerful: A platform for many uses outside of games. Imagine playing a game at one moment, then switch your SD card and having a small, low-power (and bandwidth) bench oscilloscope, or maybe a data-logger? What about a serial terminal (with some kind of small keyboard, maybe?). Or a small controllable display for your Arduino project prototyping needs?

Hope these ideas and thoughts help - I would really love to see this happen!

:slight_smile:

This

might be of some inspiration too (it doesn't have SD card though).

My bad :slight_smile: Still my point holds, that it is possible to make something like that system, only not with that good graphics :slight_smile:

cyclegadget:
Here is what claims to be Asteroids with Arduino it has sound in the video and a link to some zip files. You will have to decide if you can use any of it.
http://www.google.com/url?sa=t&rct=j&q=arduino%20asteroids&source=web&cd=3&ved=0CDYQtwIwAg&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJ7hnglh-dEQ&ei=Xt3sTsyPMeWFsgKE0bClCQ&usg=AFQjCNF5IYSVQt4EO5lkVTGem9ac6kjo-w&cad=rja

I have found that library Arduino Playground - GLCDks0108 it's for BW displays as I understand, but that's okay. I guess I can start with that :slight_smile: Aftaral I'm not trying to make new Nindendo4DS :slight_smile:
Also it seems fairly simple to use.

But I think I will need to use mega, not uno, because this display interface uses pretty much all existing pins on arduino uno. Plus having more flash for code is better.

cr0sh:
I believe that it is possible to do as you are wanting to do, and I have believed this for a long time (I have some posts about this in the old forum, as well as here in the new forum - look 'em up for my thoughts on it, some of which I will share here as well).

Great :slight_smile:
Can you please give me a link, because I can't find them.

cr0sh:

Omnipotent:

  1. What arduino board should I choose? I think mega is the best choise in this case.

Maybe a mega would be better, but my thoughts on the project have always leaned toward a multi ATMega328 solution, with a single "master" controlling multiple "slave" processors (one for controls/input, one for music/sound, and one for display) via I2C, SPI, or some other hardware serial (or parallel, if needed) interface. Really, I2C and/or SPI would be the better choice, as you can hang multiple things off the bus (addressable), and use few pins (this means that, in theory, you could use smaller processors - like the ATTiny - for maybe sound and the control input processors).

But I won't be able to fit everything into portable case... If I build it using custom PCB and separate microcontrollers, then yes. But using several arduino borads is kind of overkill :slight_smile:
I want to start with something reasonably simple, as I'm not a pro with all that. But if it works out I guess I can try building something as you described.

cr0sh:
The thing the larger ATMega1280 or 2560 will give you is RAM and flash memory, both of which could be important to this project; so perhaps make one of those be the "master" processor, but off-load the rest to other processors on a serial bus.
Note also that the ATMega644 is a reasonable alternative (as you posted regarding the Uzebox) that, and comes in a DIP format (which could be useful for a handheld device, as well as for prototyping on a breadboard). Alternatively, there are some small footprint Mega boards out there as well (even the standard Mega is pretty small, though, IMO); ultimately, you're going to want to do a lot of "standalone" devices for this project, if you intend to actually package it in a handheld case design, I think.

But I will need to use different library to program for that, right? Because as I understand default arduino library + IDE are not supporing this microcontroller. Plus I will need a programator.
That's not a big deal, but not for a newb like me :slight_smile:
For first project I want something reasonably simple. Basically take arduino, stick a screen to it, then add buttons and buzzer and sd slot and that's it :slight_smile:

cr0sh:

Omnipotent:
2. What display to choose, and how exactly can I send signal to it and display something? If you can provide link to some tutorials it will be extremely helpful!

I would actually go for a monochrome display using the KS0108 chipset; the popular size (which fits well with the ATMega328 memory footprint) has a 128x64 pixel display (and there are a few games done on the Arduino out there which have used this display). You may or may not be able to get a "full color" display to work; such displays need more memory, and there aren't many large ones that are easy to interface with (many seem to need constant refresh signal sent, pulling from an off-board memory buffer; there are some, though, which are SPI based with on-board memory - but they tend to be tiny). Something you may want to look into, if you use a monochrome display, is a controllable RGB backlight, which could be used (potentially) to add "special effects" lighting...

Thank you! That is great suggestion. I found this library
http://www.arduino.cc/playground/Code/GLCDks0108
and it seems really easy as I said in previous post, so I will definitely start with that kind of display.

cr0sh:

Omnipotent:
3. Can arduino run code from sd card or is it must only be on its flash to run...?

No - it must be on the flash to run.

Then, as I understand that Uzebox uses something like custom interpretable language for games, programs on which are loaded into memory and then processed?
Should I go for such approach for games, or will it be just too slow? In that case how can I run stuff off SD card?

cr0sh:
Suffice to say, you can get an ATMega to make great sound (granted, doing so while doing other things, like graphics, game logic, etc - may or may not be that easy; if you want to have any hope of pulling -that- off, use timer interrupts to drive the sound output from a buffer that you feed outside the interrupt routine; really, it would be easier to simply off-load the sound to a dedicated microcontroller on a serial bus).

Okay, I will then start with just buzzer for simplicity :slight_smile:
And if everything will go as planned maybe I will try to add dedicated sound chip :slight_smile:

cr0sh:

Omnipotent:
7. Is it even doable, this whole project? Will arduino have enough power to run games like mario at decent fps?

Mario? That's probably reaching a bit (maybe) - but things like Asteroids, PacMan, or similar "old school" style games that don't require much in the way of memory; I have no doubt that it is possible.

Actually I'm more interested in roguelike game for that "console". I think that it's possible.

cr0sh:
People have already created similar "standalone" games of such nature on the aforementioned KS0108 LCD for the Arduino; heck, with the right programming and data management techniques (like those used on the Uzebox), you might even be able to create a version of Mario or other tile-scrolling game. I would suggest studying how such games from the past were created, and the techniques used, and scale those to work with the footprint of the Arduino you plan to use.

I will, thank you.

cr0sh:
I wish you all the luck and I hope to see somebody build such a system - I have long thought this would make a great project, but I've had too much on my plate to pursue such a thing. Something else to keep in mind (and something I have mentioned before in similar discussion threads) is that if you set the whole system up right, you can make this "game hardware" into something much more powerful: A platform for many uses outside of games. Imagine playing a game at one moment, then switch your SD card and having a small, low-power (and bandwidth) bench oscilloscope, or maybe a data-logger? What about a serial terminal (with some kind of small keyboard, maybe?). Or a small controllable display for your Arduino project prototyping needs?
Hope these ideas and thoughts help - I would really love to see this happen!
:slight_smile:

Again, thank you for your reply. All that you wrote really helped me. I think I now have basic understanding how everything fits together and how it will work. I will start with a screen, then add buttons, then buzzer, and then SD card etc. gradually working to something like what I planned.

cr0sh:

Omnipotent:
6. Can arduino produce actual sound or only buzz? (as I've seen in youtube videos)

Programmed right (ie - you need to be a "god programmer" in the "demo scene" to pull it off) you can get an ATMega equivalent to emulate a SID chip (and more), if you so desire:

Craft

In this case, it was an ATMega88...check out his other demos, and check out his SID emulator (The hardware chiptune project) - aka "chiptunes" if you know that term...

Suffice to say, you can get an ATMega to make great sound (granted, doing so while doing other things, like graphics, game logic, etc - may or may not be that easy; if you want to have any hope of pulling -that- off, use timer interrupts to drive the sound output from a buffer that you feed outside the interrupt routine; really, it would be easier to simply off-load the sound to a dedicated microcontroller on a serial bus).

I wouldn't quite say that being a "god programmer" is neccessary :slight_smile:
But it's definitely not the easiest thing. But it's definitely possible!

Here are some examples:
My project:
http://arduino.cc/forum/index.php/topic,82475
I've also got a very low-res display, if I wanted, I could make a very low res game on it with awesome audio.
It has an 8x16 RG led matrix display, and I even put the classic d-pad and ab buttons arrangement. XD

The synth that I based some of my code on:
http://arduino.cc/forum/index.php/topic,80569.0.html

Compare those to the original gameboy, it only had 2 pulse waves, 1 sampled waveform, and 1 noise track, if I remember correctly. :stuck_out_tongue:

The code for those synths is non-blocking, it uses the timer interrupt on one timer. It's also not too processor taxing, so it's possible to do other things like update a display at the same time.

I think this project is plausible, though I'd definitely recommend not fully jumping into it at first. Learn to do each part step by step. Some parts probably will be a bit difficult.

Okay, I just ordered arduino mega from ebay :slight_smile: It's gonna be at my place in about two weeks.

Also I'm not going to use arduino IDE and libraries. I experimented with Proteus 7 and AVR Studio 5. Everything seems great and I think I will write everything myself instead of using default stuff. The point of this project is to figure out how everything works, afteral :slight_smile:

Also I went in my local electronics store, they sell breadboards and all necesary electronic components, well, almost all :slight_smile:

So I will post here once I've got all the stuff.