Intro: 8-bit Arduino Gaming
This will be a simple tutorial on how to build a 8-bit gaming setup using an arduino.
Step 1: Components Needed
1. Arduino (https://www.arduino.cc/)
2. Arduino IDE (https://www.arduino.cc/)
3. Breadboard or Vero Board (according to your need)
4. Nokia 5110 graphical display (https://amzn.to/2N9PUd9)
5. Tactile push buttons (https://amzn.to/2Byqwwy)
6. 12 ohm resistor
7. A buzzer
8. Wires to connect
Step 2: Connecting and Testing the Display
Before starting with the project it's best to pair up the screen with the arduino and test if it's working or not.
Now, your display will have 8 ports: Vcc, LED, Ground, Rst, CE, DC, DIN and CLK (not in order, check out your manufacturer or the site where you buy it from) .
Connect the Vcc to the 3.3V power supply on the arduino and the LED and ground port will both go to the GND pin in the arduino. Connect the rest of the ports as mentioned in the code. RST-12, CE-11,DC-10,DIN-9,CLK-8.
Now run the code and if everything works fine you should be able to see all the pixels on the screen turn black and the backlight turn on.
##DO NOT SOLDER THE CONNECTIONS MENTIONED IN THIS STEP PERMANENTLY##
Step 3: Make the Final Connection: Screen and Swiches
(*I know my project seems messy because i didnt have the stuffs to make a custom PCB board for it. So i went for the old school style*)
Essentially there shall be 4+3=7 buttons for your gamebuino. 4 buttons for the D-pad (up, down, right, left) and the rest 3 (A, B, C) for other functions.
Reconfigure the connections in the board according to the code.
Do not change the macro names in the code.
#define SCR_CLK 13;
#define SCR_DIN 11;
#define SCR_DC A2;
#define SCR_CS A1;
#define SCR_RST A0;
#define BTN_UP_PIN 9;
#define BTN_RIGHT_PIN 7;
#define BTN_DOWN_PIN 6;
#define BTN_LEFT_PIN 8;
#define BTN_A_PIN 4;
#define BTN_B_PIN 2;
#define BTN_C_PIN A3;
#define BuzzerPin 3;
Connect the Vcc, Backlight and Ground port of the display as mentioned in the previous step and the rest of the ports according to the macro definations mentioned here.
Solder the buttons on your perf board. One terminal of the buttons goes to the individual ports of the arduino as mentioned in the code. Connect the other terminal of all the buttons together and connect them to the ground after connecting the resistor ( the resistor is used to prevent short circuiting otherwise without the resistor current will flow directly from the arduino ports to the ground ). Connect the buzzer too.
Step 4: The Software Part and Your Games.
Open your browser and search for Gamebuino wiki ( http://legacy.gamebuino.com/wiki/index.php?title=M... ). Head over to the downloads section on the website.
- Download the arduino IDE ( http://arduino.cc/en/main/software ) and have it installed on your computer.
- Download the gamebuino library ( https://github.com/Rodot/Gamebuino/archive/master... )
- Also Adafruit-GFX-Library ( https://github.com/adafruit/Adafruit-GFX-Library )
- Adafruit-PCD8544-Nokia-5110-LCD-library ( https://github.com/adafruit/Adafruit-PCD8544-Noki... )
First download the arduino IDE and have it installed on your computer.
Download the other libraries and extract them. ( Have your antivirus turned off or extract them in a DO NOT SCAN folder because antivirus softwares sometimes mess up with the library files and your code doesn't work even though they are not malicious files ).
Copy those extracted library folders.
Now go to your Arduino libraries folder (program files->arduino->libraries). Paste the copied folders here.
To test if everything is running good or not I have attached a Pong solo game. Compile the script on your arduino IDE and then upload it to the board. If this is running everything is fine.
To play other games:
Head over to the gamebuino wiki page and go to the games section. Here you can find many games uploaded by hobbyist game developers. They are free to download. Download one of them and extract them in a similar way like you extracted the library folders.
Open the extracted folder and try to search for the .ino file. Open that in your IDE and copy paste the button and LCD port macro defination code mentioned in the previous step. Copy paste the code right at the beginning of the game source code. DO NOT CHANGE THE MACRO VARIABLE NAME.
I have attached a pong_solo game (yes, it is the entire game just compile upload and play) and the example of what you should do in the zombiemaster ino file (download the zombie master game and make changes like I made at the beginning)
If everything works fine go ahead and enjoy . :)
If you want to be a part of the gamebuino community head over to the gamebuino wiki and you can make your own games and stuffs.