Homemade Video Game Console Powered by Arduino

by BuzoBuilds in Circuits > Arduino

3235 Views, 20 Favorites, 0 Comments

Homemade Video Game Console Powered by Arduino

IMG_2212 (3).PNG
Building a Video Game Console Powered by Arduino with LED Matrix without Libraries
IMG_2211 (2).PNG
IMG_2215.PNG
IMG_2213.PNG
Copy of arduino powered game console thumbnail.png

Mom won't let you get the newest PlayStation? Just make your own then, with this instructable. In this guide, using two libraries created by BuzoBuilds (myself :)), we will create a video game that can run on the Arduino mega, turning the Arduino into a video game console!!!

Youtube Channel: https://www.youtube.com/channel/UCPmbcK8IcX0D4Fib...

Supplies

1 Arduino Mega (https://www.amazon.com/ARDUINO-MEGA-2560-REV3-A000...) Serves as the computer/CPU of the video game console

1. 32X64 LED Matrix with power cables https://www.amazon.com/Full-Color-Display-Raspberr...) Serves as the output/screen of the video game console

1 large Breadboard (https://www.amazon.com/Breadboards-Solderless-Brea...) Used as the base of the video game controller

6 Tactile Buttons (https://www.amazon.com/dp/B01MRP025V) Used for the controller

2 Quad 2 input OR Gate Chips (https://www.amazon.com/dp/B07XXXQBRH) Used for the controller

Male to Male, Male to Female, and Female to Female Breadboard Jumper Wires (https://www.amazon.com/dp/B01EV70C78 ) Connects the different components together

Pull Down Resistors, 10K Ohm should be sufficient, (https://www.amazon.com/Projects-100EP51210K0-10k-R...) used to ground the switches

1 5V DC Power Supply/Adapter (https://www.amazon.com/dp/B08VRZJV7B) Used to power the LED matrix

1 9V DC Power Supply/Adapter (https://www.amazon.com/dp/B06Y1LF8T5) Used to power the Arduino

Making the Controller

circuit.png

The controller is the input mechanism for the video game console.

1. Place 6 tactile buttons on the breadboard

2. On one side of each button, connect each button to the breadboard's ground rail with a resistor

3. Connect the other side of the buttons to the voltage rail

4.On the ground side of each button, connect the ground side to an OR gate

5. For each button, connect another wire to the ground side of the button, leave the other end of the wire open (it will connect to the Arduino later)

6. Connect the OR gates outputs into other Or gates inputs as shown in the diagram, for the final OR gate, leave the output open (it will connect to the Arduino later)

Wiring All of the Major Components Together

Capture2.PNG
circuit.png
backOfLED.PNG

In this step we will wire the Arduino, the LED matrix, and the controller, which we just made, together. There's a lot of flexibility when it comes to the wiring, so I'll just focus on my specific wiring configuration. With that said, feel free to wire the components however you want :)

Controller buttons:

There are 6 buttons on the controller. From right to left, top to bottom order, I will refer to the buttons as right button, up button, down button, left button, A button, and B button

1. Wiring the controller to the Arduino

The open wire that is connected to the OR gate will be the controller's interrupt wire

interrupt wire -> Arduino digital pin 2

Up button's open wire -> Arduino digital pin 3

Down button's open wire -> Arduino digital pin 4

Left button's open wire -> Arduino digital pin 5

Right button's open wire -> Arduino digital pin 6

A button's open wire -> Arduino digital pin 7

B button's open wire -> Arduino digital pin 8

Connect the Or gates to power and ground rail

connect the power and ground rails to the Arduino's 5v pin and GND pin respectively

2. Wiring the LED matrix to the Arduino

The input pins on the back of the LED matrix are listed in order from left to right and from top to bottom.

r1 -> Arduino digital pin 22

g1 -> Arduino pin 23

b1 -> Arduino pin 24

gnd -> Arduino gnd pin

r2 -> Arduino digital pin 26

g2 -> Arduino digital pin 27

b2 -> Arduino digital pin 28

E -> Arduino digital pin 29

A -> Arduino digital pin 30

B -> Arduino digital pin 31

C -> Arduino digital pin 32

D -> Arduino digital pin 33

clk -> Arduino digital pin 34

lat -> Arduino digital pin 35

OE -> Arduino digital pin 36

gnd -> Arduino gnd pin

Install Required Libraries

libs.PNG

1. Download the BuzoBuilds Arduino LED Matrix Library and the BuzoBuilds Arduino LED Matrix Library from the following links:

https://github.com/BuzoBuilds/Arduino-LED-Matrix-L...

https://github.com/BuzoBuilds/Arduino-LED-Matrix-G...

2. Put the repos into your Arduino libraries folder

Code the Video Game

space_dash_code.PNG

The video game program will be an Arduino sketch, which will depend on the libraries from the last step.

Here's an example of a video game sketch that you may use, perhaps as a template: https://github.com/BuzoBuilds/BuzoBuilds-Space_Das...

The following are generic steps on using the libraries to program a video game

1. Import the two libraries (LED_Matrix_Lib.h and LED_Matrix_Game_Lib.h)

2. Declare a DataMatrix, FrameRateController, and, Controller variables. They can be called anything but I'll refer to the variables as dm, fc, and controller respectively.

3. Create classes for the objects (player, enemies, interactable) that will be in the game, make the classes inherit from GameObject. Can create initialization functions for each class, which could set up the position of the objects and configure its Colliders (spelt as Colider in the library :) )

4. Overwrite the draw(int state) function for each of the GameObject based classes. This function should call DataMatrix functions on the DataMatrix variable that was declared earlier to draw the image of the GameObject on the DataMatrix's bitmap.

5. Declare your GameObject variables

6. Make a static function for the controller interrupt and within the static function place only this line "controller.controllerInterruptHandeler()"

7. In void setup():

a. Call the following functions (refer to library comments for specific documentation on functions):

fc.initFrameRateController(DESIRED FRAMERATE);

dm.clearDataMatrix();

setMatrixAddyToZero();

init_LED_Matrix(LED MATRIX PINS);

controller.initController(CONTROLLER PINS);

attachInterrupt(digitalPinToInterrupt(CONTROLLER INTERRUPT PIN),STATIC CONTROLLER INTERRUPT FUNCTION, CHANGE);

b. Initialize GameObject variables

8. In void loop():

a. Call fc.setFrameStartTime();

b. Call the draw(int state) function for all active GameObjects that should be displayed

c. Call drawLEDMatrix(&dm)

d. Handle input and then call controller.inputProcsessed();

e. Handle the rest of the game logic for the frame

f. At the end of void Loop(), call fc.waitTillNextFrame();, dm.clearDataMatrix();, clearScreen();

Plug and Play and Improve !!!

IMG_2211 (2).PNG

And finally upload the Arduino sketch, Plug in the LED matrix and Arduino and Prestro!!!

Now that we have a game and a game console, lets freaking play it lol :)

We can also try to improve the game that we made and add more features. The space dash game lacks a game over feature, so perhaps one of you fellows can add one.

Also, contributing to the libraries on GitHub is another option, for those who want to take things to the next level.

Happy coding :)