Project 20 - An LED Matrix (CleO IO )

<< Click to Display Table of Contents >>

Navigation:  Projects >

Project 20 - An LED Matrix (CleO IO )

This project uses the MikroElectronica 8x8 LED Click to create the dot matrix animations. Any one of the four different animations is selectable via the buttons on the CleO50 display. The Mikroe 8x8 LED Click is connected the CleO IO hardware.

 

 

Component(s)

 

This project uses the following component(s) -

 

Mikroe 8X8 LED Click

CleO IO

 

 

Wiring Diagram

 

 

Project 20 - LED Matrix

 

 

Code

 

The Setup() routine sets up the CleO50 display and configures the MAX7219 LED driver on the 8x8 Click to "no decode" operation as shown in the below code snippet -

 

/* Initializes CleO and the 8x8 Matrix (MAX7219) to "normal mode" */

void setup()

{

 pinMode(CLICK_CS_PIN, OUTPUT);

 unsel();

 CleO.begin();

 Click.Initialize(WRITE, true);

/* Initialize the CleO display */

 CleO.Start();

 CleO.Show();

 State = TAG_PACMAN; /* default selection is PACMAN */

}

 

The loop() routine monitors the touch events until a particular animation button is selected. Each animation is an independent state which loops continuously until the user selects a new animation. The currently selected button is rendered as a "flat" button. The setjump() and longjump() functions are used to return to the loop() if a touch event is detected in any of the animation states.

 

void loop()

{

 setjmp(jump_buffer); /* Jump here on detecting a new touch */

 clear_martix(); /* Start from a clear state */

 update_cleo(State); /* Update CleO display */

 /* Run animations on the LED matrix */

 if(State == TAG_PACMAN) run_pacman();

 else if (State == TAG_SPIRAL) run_spiral();

 else if(State == TAG_ALIEN) run_aliens();

 else if(State == TAG_STRING) run_string();

 else get_touch();

}

 

Bitmaps for all the images displayed on the 8x8 LED matrix are stored as arrays in the Arduino program memory to save SRAM. Each bitmap is 8 bytes in length, with each bit corresponding to a LED in the matrix. For example, the bitmap for a Pacman image is shown below -

 

const uint8_t PROGMEM pacman[] =

{

 B00111100,

 B01111110,

 B11011100,

 B11111000,

 B11111000,

 B11111100,

 B01111110,

 B00111100

 };

Similarly fonts are also stored in the program memory, each character requires 8 bytes of storage. For example the letter 'X' looks like this:

 

 B00000000,

 B11000110,

 B11101110,

 B00111000,

 B00111000,

 B11101110,

 B11000110,

 B00000000

 

 

Output

 

 

Project 20 LEDClick