This instructable shows you how to build a portable snake game device.
You can play the game on a 8x32 LED matrix, and control it with the help of a joystick. There are two bonus LEDs, which are some power ups, double points or you can go through walls.
You can play on different difficulties.
I'm planning to make other games too, which can be played with the Joystick and the Potentiometer.
I won't go into the details about the programming, if you are interested in it ask me about that. If you have any other questions about the project I'm happy to help.
Step 1: Collect Everything
Things you need:
- Arduino Uno + Power cable
- 8*32 led matrix (MAX7219 Dot Matrix Module, 4 In One Display with 5P Line)
- 4Bit led (SM420561k-32)
- 10kΩ potentiometer
- 2 x 220Ω Resistor
- Joystick module (KY-023 XY-axis joystick module)
- Green led
- Blue led
- A bunch of jumper wires
-Download the snake.ino sketch
To make the box, and the fix the parts (you can do the project without these, simply fixing everything on a single panel)
- 4x 15cm *12.5cm wooden panel
- 2x 12.5cm * 12.5cm wooden panel
- Hot glue
Libraries you need to be installed:
Important: You might need to edit the MAX72xx.h file to set the type of matrix you are using.
Step 2: Prepare the Box
Cut one of the 15x12.5cm and one of the 12.5x12.5cm wooden panels as shown on the pictures. The 15x12.5 panel is going to be the top panel, and the 12.5x12.5 be the left panel.
Glue the parts together as shown. Place the 15x12.5 rectangle on the button. Glue two other rectangles on their longer sides. The square panels are going to the left and right sides. Do not glue the top part yet.
Step 3: Connecting the LED Matrix Display
First of all, connect the Arduino 5V to the + on the Breadboard, and the Gnd to the -
Upload the sketch to the Arduino, then plug out the USB cable.
The led display has 5 pins, connect them like:
- VCC to +
- GND to -
- DIN to Arduino D11
- CS to Arduino D10
- CLK to Arduino D13
Plug in the USB, if you see characters on the display, it works fine.
Step 4: Connect the 4bit Led Display
Place the display above the 2x2cm hole, and glue it. Than connect the jumper wires to the pins.
Pins on the display are from 1-12. 1-6 is on the top from left to the right. 7-12 is on the bottom also from left to the right.
- 1 to Arduino D5
- 2 to Arduino D6
- 3 to Arduino D7
- 4 to Arduino D8
- 5 to Arduino D9
- 6 to Arduino D19/SCL Pin
- 7 to Arduino D0
- 8 to Arduino D1
- 9 is not in use now, because we don't need the dot.
- 10 to Arduino D2
- 11 to Arduino D3
- 12 to Arduino D4
Plug in the USB cable, if you see 0000 on the display, it's fine.
Step 5: Connect the Joystick
- GND to -
- 5V to +
- VRx to A0
- VRy to A1
- SW to A2
You don't have to stick it yet.
Step 6: Connect the Potentiometer
Connect the potentiometer as shown on the picture. Then fix it with hot glue as shown. Then place the helmet on the potentiometer and check it whether you can rotate it properly.
Step 7: Glue the LEDs
Place the LED through the hole, stick it there with hot glue. Connect the jumper wires to the LED leads, stick them with hot glue for a better connection.
Step 8: Finish the Box
Glue the top to the box, be careful with the jump wires. Than glue the LED matrix to the middle and the Joystick to the bottom right side. Lead the jumper wires throuht the gaps between the panels.
Connect the power cable to the Arduino on the bottom, and upload the given code.
Step 9: How to Play
POINTS: It shows your last score
REC: It shows your best score
DIFF: You can set the difficulty here with the potentiometer
You can change the screens with the joystick, by pulling it left or right.
How to play
- Control the snake with the joystick. Up, down, left or right but pay attention because you can turn back and die instantly. (For example if you are going up and the you pull down the joystick..)
- Hold the joystick in the direction you are about to go.
- When the green light turns on you can go through walls
- When the blue light turns on you get double points
- You can get those power-ups when you pick up a point
Difficulties are from 0-10.
- Higher difficulty means faster starting speed
- And you get less frequently power-ups