##
Matrix Tutorial

# 1. Introduction

The matrix library was written for an 8 * 8 single color matrix. By default the pins are connected to:

Anode 1 = P1.20

Anode 2 = P1.21

Anode 3 = P1.22

Anode 4 = P1.23

Anode 5 = P1.28

Anode 6 = P1.29

Anode 7 = P1.30

Anode 8 = P1.31

Cathode 1 = P0.10

Cathode 2 = P0.11

Cathode 3 = P0.19

Cathode 4 = P0.20

Cathode 5 = P2.8

Cathode 6 = P2.11

Cathode 7 = P2.12

Cathode 8 = P2.13

All files that are needed are available in the repository. The matrix library can be found on the *path Libraries > Matrix*. There’s also a special tool in the repository to generate a single frame, it can be found in the folder *Tools*. There’s also an example written in COIDE which can be found in the folder *Examples > Matrix_COIDE* .

**Warning**: The matrix library uses Timer 1; this timer can't be used by other applications at the same time.

# 2. Includes

To begin it is needed to include the libraries. This is done by these commands:

**#include** "lpc17xx.h"

**#include** "matrix.h"

**#include** "matrix_font.h"

**#include** "timer.h"

# 3. Initialize

This function initializes the GPIO and Timers which are needed by the matrix.

**Matrix_Init();**

When the matrix is initialized, the matrix will still not work. A second command is needed to start the matrix library with multiplexing.

**Matrix_Start();**

# 4. Draw lines

There are two commands to draw line. The first command is to draw horizontal lines and the second to draw vertical lines.

**Matrix_Drawhorizontalline(x,y,length);**

**Matrix_Drawverticalline(x,y,length);**

** 5. Move**

It is possible to scroll the image over the screen in four directions.

These commands move the image on the screen by 1 line.

**Matrix_MoveLEFT();**

**Matrix_MoveRIGTH();**

**Matrix_MoveUP();**

**Matrix_MoveDOWN();**

** 6. Text**

There are two options to put text on the matrix. The first one shows only a single character on the matrix:

**Matrix_PutChar(****'3'****);**

** **

The second command is to scroll a string over the screen.

**Matrix_PutString(****"HELLO WORLD! \0"****);**

**Warning:** Not all characters are available yet. Please check the Matrix_font library to check which characters are available. If a character does not exist, the matrix will be blank.

Please note that the \0 is required at the end of the string.

The slide speed of the command put string can be modified in the file *matrix.c.*

250 is the sliding speed in miilliseconds. Every 250 milliseconds the image will slide one pixel to the left.

**#define** SPEED 250

** 7. Custom text**

The whole matrix can be cleared with the command:

**void** **Matrix_Clear**(**void**);

There is a special tool in the repository to generate a hexadecimal code for a single frame.

This hexadecimal code can be saved in a character array like this:

**uint8_t smiley[] = {0x3C,0x42,0xA5,0x81,0xA5,0x99,0x42,0x3C};**

** **

The function Matrix_NewFrame converts the above hexadecimal code to a picture on the matrix:

**Matrix_NewFrame(smiley);**

** **

The multiplexing can be stopped with the following command:

**Matrix_Stop();**