Pages: [1]   Go Down
Author Topic: OO Snake Game with 32X16 RG Bicolor LED Dot Matrix and Joystick over serial  (Read 113 times)
0 Members and 1 Guest are viewing this topic.
Cardiff, UK
Offline Offline
Jr. Member
Karma: 0
Posts: 70
Programmer of all sorts
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I thought I'd just share this as I've just recently upload it to Googlecode

I purchased a couple of 32X16 RG Bicolor LED Dot Matrix boards and thought I'd write a game for one of these displays.
I settled on a relatively straight forward game called Snake and decided to write using object oriented principles.  I had seen a number of versions of the game and each one consisted of a single file with all the code shoved in it.  I decided to write a structured code that would logically represent the game and demonstrate some of the object oriented techniques with Arduino. 

The solution I present relies on encapsulation and contains interfaces which allow you to easily add new input and display hardware whilst keeping the code maintainable.

There is a Vine video on my profile here that shows a command line program that can send joystick control to the Arduino


The screen I used came from here:

You could use any other display you like.  Have a look at sure32x16.cpp to see how that implements the interface in display.h.  Your new class will have to implement the same methods to work.


Serial input is enabled by default but you can also use hardwired buttons if you comment out

#define SERIAL_INPUT 1

and uncomment

//#define BUTTON_INPUT 1

in the types.h file.

The methods of input can be easily extended.  Just like the display you can add new classes to handle whatever input method you like.

This proejct also contains code written by other people:


JChristensen's Arduino library to debounce button switches, detect presses, releases, and long presses


Arduino library for HT1632C based led dot matrix displays (eg. Sure Electronics).

My Arduino 7 segment LCD/LED library

Pages: [1]   Go Up
Jump to: