Google+ Facebook Twitter Pin It Reddit
Electronics Fundamentals

Working with LED Dot Matrix Displays

Electronic Fundamentals Part 1: Monochrome dot matrix displays


LED Dot Matrix Displays

Introduction

Unlike 7 segment displays you can use dot matrix displays to generate alpha, numeric, or custom character output. This is s a quick introduction to the basics of using monochrome LED dot matrix displays with microcontrollers.

Structure and operation of LED dot matrix displays

In a LED dot matrix display the LEDs are located at the column and row intersections of the matrix. LEDs in the same row are connected together as are LEDs in the same column. Figure 1 shows two common configurations for LED matrix displays.

LED dot matrix configurations – CCAR and ACCR
Figure 1: LED dot matrix configurations – CCAR and ACCR


In the matrix (figure 1) on the left the positive terminals (anodes) of the LEDs are connected to the rows and negative terminals (cathodes) are connected to the columns. This is sometimes specified in the manufacturer’s data sheet display as Cathode Column, Anode Row (CCAR). In the matrix on the right the connections are reversed – anode column, cathode row (ACCR).

Click here to Purchase the Dot Matrix Driver Circuit

Time Required: 1-2 Hours
Experience Level: Intermediate

5x7 Dot matrix Driver Circuit Kit Includes:

(1) Arduino Uno R3 DIP Edition (Revision 3)
(10) 220 Ohm 1/4 Watt 5% Carbon Film Resistor
(10) 2N3904 NPN General Purpose Transistor
(10) 1kΩ 1/4 Watt 5% Resistor Carbon Film
(1) 830-Point Solderless Breadboard 6.5" x 2.125"
(1) ZipWire 40 Piece 20cm Male to Male Colored Jumper Wires
(1) 9V Battery Snap with 2.1mm Barrel Plug
(1) 9V Energizer Alkaline Battery
(1) 5x7 LED Dot Matrix Display Red-Orange CC/AR DIP-14

Required tools and parts:

Computer with available USB port and Arduino IDE installed.

There are not enough pins on an LED dot matrix display package to directly access all of the LEDs in the matrix at the same time. For example a typical 5x7 monochrome dot matrix display has 35 LEDs but comes in a 12 or 14 pin package. As you see in figure 2, the pins are arranged internally so that each one controls a specific row or column.

LED dot matrix pin diagram
Figure 2: LED dot matrix pin diagram.


Accessing individual LEDs

You turn on an individual LED by setting its row and column pins to the proper polarity. For example, referring to figure 3, in the CCAR matrix on the left the switch in row 1 is closed (shown in red) causing a positive voltage level to be applied to the anodes of all of the LEDs in that row. The switch in column 2 is also closed which ties the cathodes of all of the LEDs in that column to ground. The LED at the intersection of column 2 and row 1 is forward biased and turns on. The image on the right in figure 3 shows the equivalent action (with opposite polarity) for an ACCR matrix.

Addressing individual LEDs in CCAR and ACCR dot matrix displays
Figure 3: Addressing individual LEDs in CCAR and ACCR dot matrix displays.


Multiplexing

Because of the limited number of pins you can only display one row or one column of LEDs at a time. To display the entire matrix you need to multiplex the columns or the rows. That is, display each column or row one at a time and do it so quickly that all of the columns or rows appear to be visible at the same time.

Column multiplexing
Figure 4: Column multiplexing


Interfacing microcontrollers and LED dot matrix displays
The circuit diagram in Figure 5 shows a 5x7 LED matrix display connected to an Arduino Uno SBC.

Arduino Uno 5x7 LED matrix display driver circuit
Figure 5: Arduino Uno 5x7 LED matrix display driver circuit


The matrix display used in the example circuit is a CCAR display. It comes in a 14 pin package (figure 6). The pins are aligned in two rows. One at the top and the other at the bottom of the package. Pin 1 is the first pin on the left of the bottom row.

LED matrix display package diagram
Figure 6: LED matrix display package diagram.


Twelve Arduino digital I/O pins are required to drive the display - 7 pins for the rows and 5 for the columns. Pins 2-6 control transistors T1 through T5 which are connected to the matrix display column pins. The transistors are required because current through the Arduino I/O pins is limited to 20 mA. Turning on just two or more LEDs in a column may exceed that limit.

Pins 7 – 13 are connected to the matrix display row pins. Resistors R6 - R12 limit the current through each row pin to less than 20 mA.

The example code in listing 1 is a simple LED dot matrix display driver that uses column multiplexing to display a pattern. The pattern to be displayed is stored in the array mBuf. Each element in mBuf contains a value that indicates whether the corresponding LED in the matrix display should be on (1) or off (0). The application simply refreshes the display with the current contents of mBuf. You can of course change the values in mBuf to display different characters or patterns.

The arrays rowPins and colPins contain the lists of Arduino I/O pins connected to the matrix display rows and columns respectively. The pin numbers appear in the array in the order that the pins are connected to the matrix display (e.g. rowPins[0] connected to row 1, colPins[0] connected to column 1).

Listing 1

   // mBuf  - 2 dimensional array (7 rows, 5 columns)
            byte mBuf[7][5] = {
                               {0, 0, 0, 0, 0},  // 0
                               {0, 1, 0, 1, 0},  // 1
                               {0, 0, 0, 0, 0},  // 2
                               {0, 0, 1, 0, 0},  // 3
                               {1, 0, 0, 0, 1},  // 4
                               {0, 1, 1, 1, 0},  // 5
                               {0, 0, 0, 0, 0}   // 6
                             };

int rowPins[7] = {7, 8, 9, 10, 11, 12, 13}; // array that holds row pin assignments
int colPins[5] = {2, 3, 4, 5, 6};           // array that holds column pin assignments

void setRowPins(int c)                      // Set the row pins to mbuff column values
  {
    int r;
    for (r = 0; r < 7; r++)
     {
       digitalWrite(rowPins[r], mBuf[r][c]);
      }
    return;
}


void refreshMatrix()                        // send the contents of mbuff to the matrix display
{
   for (int c = 0; c < 5; c++)
    {
      setRowPins(c);
      digitalWrite(colPins[c], HIGH);
      delay(2);
      digitalWrite(colPins[c], LOW);
    }

  return;
}



void setup() {
  // put your setup code here, to run once:
for (int c = 0; c < 5; c++)
  {
    pinMode(colPins[c], OUTPUT);                    // initalize column pins
  }

for (int r = 0; r < 7; r++)                                     // initialize row pins
  {
      pinMode(rowPins[r], OUTPUT);
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  refreshMatrix();                                  // updates the Led dot matrix display
}


On each iteration of the main loop, the function refreshMatrix updates the LED dot matrix display with the contents of Mbuf, one column at a time. Function refreshMatrix calls the function setRowPins to set the Arduino I/O row pins according to the values found in the rows of the current column. After the row pins have been set, refreshMatrix sets the appropriate Arduino I/O column pin to turn on the transistor for the current matrix display column. The LEDs that are forward biased will turn on. After a short delay, refreshMatrix turns off the transistor and goes on to the next column. This cycle is repeated so quickly that, due to persistence of vision, the LEDs appear to be on at the same time.

5x7 Dot matrix driver circuit
Figure 7: 5x7 Dot matrix driver circuit.

Discussion Questions:

1. How would you address the matrix if the polarity were reversed? (anode column/cathode row)
2. How do dot-matrix displays work?
3. If not for multiplexing, how many pins would this 5x7 matrix require?
4. Of all possible digit forms, which make up the least confusable fonts?