# Lesson 15 Dot Matrix LED Display

##### Share for us

Introduction

With low-voltage scanning, dot matrix LED displays have advantages such as power saving, long service life, low cost, high brightness, a wide angle of view, long visual range, waterproofness, and so on. They can meet the needs of different applications and thus have a broad development prospect. In this experiment, we will make it display some simple characters like numbers and letters to experience its charm from the beginning.

Components

– 1 * SunFounder Uno board

– 1 * Dot-matrix (8*8)

– 8 * Resistor (220Ω)

– 1 * Breadboard

– 2 * 74HC595

– 1 * USB cable

– Jumper wires

Principle

Dot Matrix

Generally, there are two types of dot matrix – common cathode and common anode. They look almost the same in appearance. But usually there will be labels for easy recognition. The one with a label ending with AX is a common cathode dot matrix and that with BX is a common anode one. See the figure below for how they look like. So the pins are distributed at the two ends of the matrix. Pins at one end (usually the label side) are 1-8 from left to right, when at the opposite they are 9-16 from right to left.

The external view:

Below is the internal structure. You can see that in the common anode dot matrix, ROW is the anode of LED and COL is the cathode, while the situation in the common cathode one is opposite. Though for both types, the columns are the pin 13, 3, 4, 10, 6, 11, 15, and 16 and rows are the pin 9, 14, 8, 12, 1, 7, 2, and 5 in the dot matrix. To light up the first LED on the upper left corner, you need to set pin 9 as high level and pin 13 as low level in the common anode dot matrix; for a common cathode one, set pin 13 as high and pin 9 as low. If you want to turn on all the LEDs at the first row, in a common cathode dot matrix, set pin 13 as low level and ROW 9, 14, 8, 12, 1, 7, 2, and 5 as high level. In a common anode one, set pin 13 as high level and those rows as low level. See the figure below for better understanding.

The internal view:

Pin numbering corresponding to the above rows and columns:

The schematic diagram

In this experiment, two 74HC595 chips are used – one to control the rows and the other, the columns. They are connected by cascading. The SHcp and STcp are shared between them. Connect pin DS of the U3 (see as above) to pin 11 of the Uno, and Q7′ of the U3 to DS of the U2 so the two chips are cascaded. Then when a 16-bit data is sent, the first 8 bits are transferred to the U3 and the rest 8 bits to the U2, thus controlling rows and columns of the dot matrix.

Experimental Procedures

Step 1: Build the circuit

Since the wiring of this experiment is a little complicated, we will do it step by step.

1)    Insert all the devices needed into the breadboard. Then connect pin 16 and pin 10 of the 74HC595 to 5V of the control board, pin 8 and pin 13 to the GND. The 788BS on the image means you should put the matrix with the side marked with “788BS” facing that direction.

2)    Connect pin 11 of the two 74HC595 chips together and connect them to pin 12 of the control board. Connect pin 12 of the two 74HC595 and then to pin 8. Pin 14 of the 74HC595 on the left connects to pin 9 on the right. Connect pin 14 of the 74HC595 on the right to the pin 11 of the control board.

3)    The 74HC595 on the left controls the ROW of the dot matrix. To prevent burning the matrix, we need to connect a 220 ohm current limiting resistor to each row. Connect Q0-Q7 of the 74HC595 to pin 5, 2, 7, 1, 12, 8, 14, and 9 of the dot matrix.

4)    The 74HC595 on the right controls the columns of the matrix. Connect Q0-Q7 of the 74HC595 to pin 13, 3, 4, 10, 6, 11, 15, and 16 of the matrix respectively.

Step 2: Open the code file

Step 3: Select correct Board and Port

Step 4: Upload the sketch to the SunFounder Uno board

Here you should see the dot-matrix display 0 to 9 and then A to F circularly.

Before starting to write the code, you need to use a font software to get the dot patterns defining the characters to be displayed and store them in an array as the data[] shows.

You can see that there are 18 rows in the array (the first and last rows are blank) x 8 columns = 144 hexadecimal numbers in total. In the array sorts, the numbers are sorted like this: 0~7 (the first row), 8~15 (the second row) and so on, till 135-143 (the last row).

This array is used to control the ROWs of the dot matrix – when the ROW is high level, the corresponding dots will brighten.

Now, let’s learn more about the array. Take the display of “0” as an example.

They are 8 hexadecimal numbers. Use a “~” (~data[num]), meaning inverting each number, and we can get 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x00 after inverting the 8 numbers one by one. Convert the numbers into binary ones: 0000 0000, 0011 1110, 0100 0001, 0100 0001, 0100 0001, 0011 1110, 0000 0000, 0000 0000. Copy the arrays to the code and you will see 0 displayed in the dot matrix.

Procedures of the displaying: In the data[] array, first display data[0](0xFF) to data[7] (0xFF):  blank in the matrix. Then data[1] (0xFF) to data[8] (0xFF): still blank. When it comes to data[2] (0xFF) to data[10](0xC1), it begins to display the left column of 0 (0011 1110). The rest goes the similar way. So we will see the matrix display the characters 0-F which scroll to the left. In order to show them clearly, repeat each display 10 times – see the for(int t = 0;t < 10;t ++).

Code