Snake game on Arduino

I’ve got multiple questions about the schematic setup. Please note that the setup depends on transistor type (PNP or NPN) as well as the led matrix (common anode or common cathode). For the Arduino software, try the second option at line 260 if the first one don’t work.

This is my first project on Arduino, using 8×8 LED matrix to make a snake game. The project code is modified from my previous Snake game on LM3S8962 Board.

What do you need?

  • Arduino Uno
  • 1 x 8×8 LED matrix
  • 2 x 74HC595 shift registers
  • 8 x B562 PNP transistors (other PNPs are OK)
  • 4 x pushbuttons
  • 8 x 330 resistors
  • 8 x 1k resistors
  • 8 x 10k resistors
  • And a lot of wires


The first thing you should take care of is the pinout of LED matrix. There are various types of LED matrix in the market. The best way is to look at the datasheet of your LED matrix and determine which pins control rows and which pins control collumns.

The first 74HC595 controls the rows of LED matrix. We connect its outputs to PNP transitors to ensure the current supply for LED matrix enough. The second 74HC595 controls the column of LED matrix.

Here is the schematic.

How does it work?

We use 2 shift registers to control 8 rows and 8 columns of the LED matrix. With 74HC595, we only need 3 Arduino pins to drive 16 output pins, equivalent to 64 LEDs. What a save!

The display data in LED matrix is stores as a bitmap (array) unsigned char led[8] . To send data from Arduino to 74HC595, we use the following functions:

Arduino sketch

In action