Become a subscriber (Free)

Join 29,000 other subscribers to receive subscriber sale discounts and other free resources.
Don't worry -- youre-mail address is totally secure. I promise to use it only to send you MicroZine.

How to drive a Dot Matrix LED Display.

Here you can find out how to drive a dot matrix LED display with 64 LEDs (8 rows by 8 columns - 8x8 display) or less e.g. 35 LEDs (7 rows by 5 columns - 5x7 dot matrix). The same principle is used for larger displays but you may need more processing power as this method requires the microcontroller to actively update the display every 20ms. Other more complex (expensive) chips do this refresh for you (see the MAX7219).

Driving an led dot matrix is quite simple and this page shows you how to do it without a complex "helper" chip i.e. driven by the microcontroller a few transistors and a the 4017 Johnson counter.

It uses persistence of vision to let you drive the 64 LED matrix with only 10 microcontroller outputs!

Normally you would need 64 outputs for 64 LEDs but by using multiplexing and a helper chip you can get away with 10 microcontroller pins. In this design two pins are use to communicate with the helper chip and 8 pins directly drive the row elements of the 8x8 display. The helper chip is used to activate each column in turn while the row pins generate the column pattern at the active column..

LED Display multiplexing simply means turning on one led for a short period of time and doing this repeatedly for each LED. 

If you do this fast enough then your eye will not notice any flicker.

The 64 leds, arranged as 8 rows by 8 columns, are housed in a plastic casing. The LEDs are no different to any other LEDs but the LED block saves a huge amount of soldering as all the wiring has been done for you within the unit itself.

It is already wired up for multiplexing having only 16 connections (8 rows are connected to 8 anodes of the LEDs and 8 columns are connected to 8 cathodes of the LEDs). So you can drive a row of LEDs by pulling the column connection to ground.

LED display matrix 8x8 LEDs

led dot matrix display block diagram

A dot matrix led display is simply a grid of LEDs arranged for use by multiplexing.


dot matrix led display driver Red 8x8 LEDs

Dot matrix  LED display project details.

Dot matrix LED display Project
Compiler Mikroelectronika MikroC Compiler Free!
Target 16F88/16F84 (retargetable to other PICs that have an enough pins).
Software level Easy.
Software notes Multiplexing the display.
Hardware level Easy.
Hardware notes No special notes
Project version 1.04
Project files Enter your details to get the Download Link
and get the microcontroller newsletter:

(Your email is safe it will never be sold or rented).
You will get All the C source code and hex file.

Note: Check your email for the project code download link.

Hardware operation

 Dot Matrix LED Display schematic
(Click diagram to open a pdf)

LED Dot Matrix Display schematic


If you tried to drive 64 individual LEDs you would need 64 individual output pins (each led connected to a output pin on one side and ground on the other).

Obviously that is a tall order so the way round it is to use persistence of vision which is a way of describing how your eye works.

Your eye reacts slowly to changes in light intensity so that if a light is turned on and off quickly enough then it does not notice that the light is off. Basically your eye remembers a light pulse for a short time.

The approximate time is 20ms so if the light is turned on at a frequency >50Hz (1/20ms) then your eye will not notice any flicker at all.

Multiplexing uses this fact to reduce the number of pins needed to drive an LED display. You can do this by splitting the 64 led display into 8 rows and 8 columns which lets you drive it using 8 row outputs and 8 column outputs. In fact the 8x8 led matrix block used here has all the leds arranged in this way already.

Dot Matrix LED display :TC15-11SRWA

kingbright led block 8x8

Note: The orientation of the led block should be pin 1 at the top left to view characters the right way up. However I found I wanted to move the board around and look from the other side so there are two definitions that allow flipping and rotating the display. To view from a different position re-compile the code with these definitions active (See the code).

Each row is driven in turn and as long as all of the rows are driven within a time period of 20ms it will appear as though the LEDs are on continuously.

To turn a specific led 'ON', data is output to the column drivers when a row is driven. 

Helper chip

To save more pins it is common to use a helper chip and in this project it is a Johnson counter (a 4017). This generates a walking one every time that it's clocked. Since you only want one row on at a time it is the ideal chip for this application.

Note: In this project when the 4017 has been reset it outputs a logic high at Q0 - which is not connected - so during reset the 4017 does nothing. This allows you to use the column driver port for something else if you want to when you are not driving the LEDs.

To drive the 4017 all you need is two pins one for reset and one for clock.

So to fully drive the 64 led display you only need 10 microcontroller output pins.

You don't have to use a 4017. If you have enough pins you could drive the led display directly e.g. using a 16F877A. It all depends on your circuit and what resources you need to use.

led dot matrix display hardware block diagram

Row current sink

To get more current through the LEDs you need to use a transistor at each row driver as the maximum current you can sink or source is low.

The row driver sinks all the current from each active row LED. To let the current flow you need to use a transistor at each row as the maximum current you can sink or source is very low for an HC4017 (1ma).

I used a ULN2803 (an array of 8 grounded NPN transistors) - which is massive over design in terms of its collector current capability (500mA) but provides a convenient (and cheap) package which is useful for prototyping.

Note you can use individual NPN transistors if you want to - normal standard transistors are OK as the maximum current is about 60mA through a column.

Character Set

The most difficult thing about using the dot matrix LED display is defining the characters. Basically for ASCII characters you need an array of 128 blocks each having 8 column data numbers.

The usual way is to get out a piece of graph paper and define your characters by drawing blocks where a pixel is on. You then translate each line into hex (binary to hex is very easy) and then transfer this information to your program source code.

I have defined characters 0-9 which are cycled continuously.

Dot Matrix LED Display Software

Project files for the dot matrix led display

Compiler project files


C Source files.


Header files.


Output files


Dot Matrix Led Display code description.


This contains all the code except :

    • 8x8 character definitions in charset8x8.h
    • Bit manipulation routines found in bit.h
    • Type definitions in types.h

The code is simple and easy to follow - all the action happens in main().

It enters a continuous a continuous loop blinking an led on port A and driving the columns of the 8x8 led display and driving the 4017 (for rows). At each blink the next character is selected from the character set.

The code repeatedly executes the for loop and it must go faster than 20ms for 8 columns - so the code has to go faster than 20ms/8 = 2.5ms - which it does. So there is no visible flicker.

At each row (selected at each iteration of the for loop) the next column data is output so that the entire character is displayed.

You can program the PIC in circuit through the ICSP connector.

Note: There are two controls for adjusting the display:

FLIPLR which swaps all the bits in each output row.

ROT180 which turns the display upside down.

You will probably get the display orientation wrong and these fix that problem in software!

New! Comments

Have your say about what you just read! Leave me a comment in the box below.

Jump from dot matrix LED display to
Best-microcontroller-projects home page

Privacy Policy | Contact | About Me

Site Map | Terms of Use

Visit our Facebook Page:

   Click Here

Recent Articles

  1. PIC PWM: Easy Pulse width Modulation on the PIC Micro.

    PIC PWM : What its for and how to use it. Including an example showing typical setup of a PIC PWM module with register settings.

    Read more

  2. The Essential I2C Tutorial: All you need to know about I2C...

    How to use I2C. In this tutorial you will learn all about the 2 wire I2C serial protocol. Learn how easy it is to use, how it works and when to use it...

    Read more

  3. PIC LCD volt meter : How to use the ADC for voltage measurement.

    A 0-5V LCD volt meter project using an HD44870 display and one PIC micro ADC.

    Read more

  4. PIC Programming using ICSP

    PIC programming : How to use ICSP for programming a PIC microcontroller giving some ICSP connection diagrams and it also shows how to use MPLAB X and ICPROG.

    Read more

  5. PIC ICSP In Circuit Serial Programming

    How to program PIC ICSP, IN-Circuit, live and still have a working programmer and operational circuit!

    Read more

  6. An Ultrasonic Distance meter project: How to make one using a microcontroller.

    Understand how an Ultrasonic Distance meter works by building one your self – including Free software to drive the microcontroller and display.

    Read more

Sign up for MicroZine
''The'' Microcontroller Newsletter

Enter your first Name and primary email address in the form below:

And receive absolutely FREE a full project for:

"Measuring Analogue Voltages
Without An ADC"

(Using only one pin).

Instant Download:
You Can
Get It Right Now

Warning: This project could be  Removed 
at any time.  

It will  NOT be 
available indefinitely SO
To avoid 
disappointment  get it:


Don't worry -- your e-mail address is totally secure. I promise to use it only to send you MicroZine
Remember this is a project with full description and fully debugged C Source code - and it's not available from the main website.

You can only get it through this newsletter.

To get exclusive access Enter your first name Name and primary email address Now in the form above.:

But wait !

There's more...

You'll receive more
free and exclusive reports as well as site information and site product updates

Scroll up to the form above and sign up NOW. Don't forget it's FREE and if you don't like it, you can unsubscribe at any time.

Click Here Now to use the form above to get your Valuable information absolutely free.

Readers Comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's


- Ranish Pottath

"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan


"Awesome site,
very, very easy and nice
to navigate!"

- Matt

Learn Microcontrollers

"Interested in

Sign up for The
Free 7 day guide:


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."

- Dave


"Your site is a great
and perfect work.

- Suresh


"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.

- Anon

Back to Top