The Snake Game is one of the classic games I remember playing on my first "Brick Game" when I was young. A fun, simple yet exciting game that I have decided to recreate in Arduino! Let's get started.
Things Needed:



Jumper Wires
Breadboard
Arduino IDE
8x8 LED Matrix and Joystick Schematic:
Credits to: Sanwandter1
For the Joystick, I used four (4) out of the five (5) pins which is responsible for the Ground, 5V Power and X and Y movements. The 5th pin is for the Switch (when you push down the joystick it makes a click sound) but for this instance, we will not be using it.
For the joystick's four (4) pins, I have connected them to the ff: in the Arduino Uno Board:
- PIN 1: GND
- PIN 2: 5V
- PIN 3: A4
- PIN 4: A5

The Code:
This portion is to initialize our variables. This is where we define what are our rows and cols from the LED Matrix. We also define which pin the X and Y are plugged into the Arduino Uno. We also set the default screen (blank) and what we can see in the Game Over screen (sad face). Other important things are declared here such as the current rows and columns where the snake's body is, variable to register which direction the snake is going, default snake direction, max length of the snake, a variable to store the snake's current length, which row and column the snake's food is and so much more.
Tip:
You can draw anything you want on the LED Matrix! The key is to control the on / off state of the lights. To explain this further, imagine you have a 8x2 LED Matrix:
B10001000
B01000000
The zeroes and ones represent a dot on the LED Matrix. When it is zero (0), it is off. When it is one (1) the light is on. In this scenario, first col first row light is on, second col, second row is on, and fifth col, first row is on. The rest are off.
