8 X 8 LED Pong With Arduino

by MaxusMetalworks in Circuits > Arduino

21331 Views, 26 Favorites, 0 Comments

8 X 8 LED Pong With Arduino

metalworks-led-pong.jpg

By Justin Ou, Creative Technologist (Intern)

This Classic Pong game was created using an Arduino connected to an 8x8 LED matrix. The pong paddles are controlled using a joystick and the game ends when the ball goes past a player’s paddle. As a challenge, the ball increases speed each time a paddle is hit. Restart the game by resetting the Arduino board.

The hardware is setup by following a tutorial on the official Arduino website at http://www.arduino.cc/en/Tutorial/RowColumnScanni...

Purchase Materials

Materials needed:

1x 8x8 LED Matrix

1x Arduino UNO

1x Breadboard

2x Joystick

30x Hook-up wires

Set Up the Hardware by Following the Circuit Diagram

metalworks-led-pong-circuit.png

Connect the hook-up wires to the Arduino pins according the diagram. Instead of potentiometers, you may follow the same wiring configuration to connect the 2 joysticks to the Arduino. Ensure that the wiring are secured to the breadboard.

Notes on LED Matrix

metalworks-led-pong-diagram.png

An LED Matrix consists of rows of common anodes and columns of common cathodes or vice versa. The pins of the LED matrix are connected to the Arduino or other micro-controllers to set the a row or column to high or low. Consider the schematic above.

With reference the the diagram above, a column must be set to HIGH to turn all any LED in the column. However, an individual LED in the row must be set to LOW to turn it on.

For example, to turn on LEDs in Column 1, set Pin 13 to HIGH and all rows to LOW. To turn on LEDs in Column 1 on Rows 3 and 4, set Pin 13 to HIGH, Pin 8 and 12 to LOW and other rows to HIGH.

Upload the Pong Sketch and Test the Game

metalworks-led-pong-closeup.png

Access the code

The game should start immediately when the sketch is uploaded. You may control the paddles using the joystick. If the LEDs do not light up correctly, you may try to replace the array of pin numbers for the columns and rows.

Replace lines 3-9 with the following code.

// 2-dimensional array of row pin numbers:

const int row[8] = {

2,7,19,5,13,18,12,16 };

// 2-dimensional array of column pin numbers:

const int col[8] = {

6,11,10,3,17,4,8,9 };

Note: If the LEDs still do not light up correctly, you have to find the correct configuration for the array of rows and columns pin numbers. Do this by removing the wires between the LED matrix and adding it back one at a time. Record the pin numbers appropriately for the LEDs that light up.

(Optional) Play Against AI Opponent

Open the sketch in Arduino and go to line 39.

Replace it with the following code:

boolean multiplayer = false;

Upload the sketch again and you may now play against an AI.