Shop OBEX P1 Docs P2 Docs Learn Events
A simple game - Snake run on 8x8 RGB LED Matrix Module + Ardunio + 5-Position switch — Parallax Forums

A simple game - Snake run on 8x8 RGB LED Matrix Module + Ardunio + 5-Position switch

This thread is moved from this thread.
http://forums.parallax.com/showthread.php?143864-Demo-code-for-8x8-RGB-LED-Matrix-Module

And I will do a little explanation to how to set up, hook up thing in this thread, make it easier for the users.

Please read the demo code instruction thread first(the link is at the beginning of current thread), make sure you can run the Arduino sample and demo code successfully, before read below.

This simple implementation of the game Snake is based on Arduino UNO platform, with 5-Position switch(Parallax Stock code #27801) , 4 or 9 units of 8x8 RGB LED Matrix Module(Parallax Stock code #32324), you will also need a breadboard or the Board of Education Shield(for Arduino) (Parallax Stock code #35000), a 3-pin cable(Parallax Stock code #800-00080).
You will need a good power supply too, 4 or more modules can not get enough power from the USB.

Most of the material can be bought from Parallax.



Set the the Device ID and PSS first.(If you haven't finished reading the thread above, go back and read it).

Connect the 5-Position switch to the Arduino, you will need 10 piece of wires, 4.7k resistor and a breadboard. A cable to connect the modules to the Arduino UNO.
Please connect the +5V and GND to the Arduino board you are using.

RGB_LED_Matrix_Arduino.JPG


The codes for 4 modules and 9 modules are not much different.
/* Different between the code for 4 and 9 modules, the display font size also changed to 0508 */


#define SIGLE_DIRECTION_LIST_LENGTH (32)  // The length of the single direction list, the game will end when reach the end of the list.
#define SNAKE_LENGTH_MIN (5)                     // the original length of the snake
#define SNAKE_LENGTH_MAX (SIGLE_DIRECTION_LIST_LENGTH-1) // the Max length of the snake


#define BUTTON_MIDDLE (2)                              // 5-position switch
#define BUTTON_UP   (3)
#define BUTTON_LEFT (4)
#define BUTTON_DOWN (5)
#define BUTTON_RIGHT (6)

/* Set the bounds to fix into 4 modules */

#define AREA_BOUND_START_X (0)                        // The snake moving area 
#define AREA_BOUND_START_Y (0)
#define AREA_BOUND_END_X (15)
#define AREA_BOUND_END_Y (15)




/* Different between the code for 4 and 9 modules, the display font size also changed to 0816  */


#define SIGLE_DIRECTION_LIST_LENGTH (32)  // The length of the single direction list, the game will end when reach the end of the list.
#define SNAKE_LENGTH_MIN (5)                     // the original length of the snake
#define SNAKE_LENGTH_MAX (SIGLE_DIRECTION_LIST_LENGTH-1) // the Max length of the snake


#define BUTTON_MIDDLE (2)                              // 5-position switch
#define BUTTON_UP   (3)
#define BUTTON_LEFT (4)
#define BUTTON_DOWN (5)
#define BUTTON_RIGHT (6)

/* Set the bounds to fix into 9 modules */


#define AREA_BOUND_START_X (0)                        // The snake moving area 
#define AREA_BOUND_START_Y (0)
#define AREA_BOUND_END_X (23)
#define AREA_BOUND_END_Y (23)

Sign In or Register to comment.