Mini Arcade Snake Game

Mini Arcade Snake Game

Arcade games are nostalgic to many of us, especially the classic snake game that came pre-installed with the Nokia 6110.

This tutorial will show you how to recreate the Snake game, using an Arduino, a ps2 joystick and an 8*8 LED matrix.

Components required:

Any Arduino board.

This microcontroller is used to interface the joystick and the MAX7219 IC(which in turn interfaces the 8*8 matrix).

An 8*8 LED matrix.

This module contains a MAX7219 IC which helps us in interfacing the 8*8 LED matrix. This unit as a whole functions as the display for the arcade game.

 

A PS2 joystick.

If you observe the joystick closely, there are two potentiometers connected on the x and y axis of the joystick. These potentiometer’s readings are used to map the joystick in either axis. These joystick mappings are read as analog inputs, which are used to control the snake’s movement in the game.

A Bread Board.

The breadboard is used for making the wiring neat and non-permanent, so any modifications later can be done without hassle.

Jumper Wires.

These wires are used to interconnect the components.

Additionally, connect a potentiometer to pin A7 to control the speed of the game.

How it works:

The PS2 joystick connected to the Arduino has two potentiometers, whose input is read by the analog pins. These inputs are mapped in the X and Y axis, which is then used to move the snake around in the game.

Initially, the snake has a size of 3 pixels. As the snake keeps eating the food (indicated by the blinking dot), it grows in size. The speed can be additionally be changed by using a potentiometer. Connect the potentiometer to pin A7 if you need to change the speed of the game.

For the display, the Arduino is connected to the MAX7219 8*8 matrix module. Here’s a blog that has more information about this module.

Code:

Open the code, and then upload it to the Arduino board once you’re done with the wiring.

Happy Gaming!

Author- Moksh Jadhav

 

Next article Digital Clock