LED matrix using shift registers

LED matrix using shift registers
This instructable is meant to be a more complete explanation than others available online. Notably, this will provide more hardware explanation than is available in the LED Marquee instructable by led555.

Goals

This instructable presents the concepts involved with shift registers and high side drivers. By illustrating these concepts with an 8x8 LED matrix I hope to provide you with the tools needed to adapt and expand to the size and layout your project calls for.

Experience and Skills


I would rate this project to be of medium difficulty:
  • If you already have experience programming microcontrollers and working with LEDs this project should be fairly easy for you to complete and to scale to larger arrays of lights.
  • If you are just starting out with microcontrollers and have flashed an LED or two you should be able to complete this project with some help from our friend google.
  • If you have little or no experience with microcontrollers or programming this is probably beyond what you should be getting yourself into. Try out a few other beginner projects and come back when you've got some more experience writing programs for microcontrollers.

Disclaimer and Credit


First, I am not an electrical engineer. If you see something that is wrong, or not a best practice, please let me know and I'll make the correction.

Do this at your own risk! You should know what you're doing or you can cause damage to your computer, your microcontroller, and even yourself.

I have learned a lot from the internet, particularly from the forums at: http://www.avrfreaks.net

I am using a font set that came with the ks0108 universal C library. Check that out here:
http://en.radzio.dxp.pl/ks0108/
 
Remove these adsRemove these ads by Signing Up
 

Step 1Parts

Parts List


General Parts

To make an 8x8 grid of LEDs and control them you will need:
  • 64 LEDs of your choice
  • 8 Resistors for the LEDs
  • 1 Shift register for the columns
  • 1 Driver array for the rows
  • 8 Resistors for switching the driver array
  • 1 microcontroller
  • 1 clock source for microcontroller
  • 1 prototyping board
  • 1 power supply
  • Hook-up wire

Specific Parts Used Here

For this instructable I used the following:
  • 64 green LEDs (Mouser part #604-WP7113GD)
  • 8 220ohm 1/4 watt resistors for the LEDs (Mouser part #660-CFS1/4CT52R221J)
  • 1 HEF4794 LED driver with shift register (Mouser part #771-HEF4794BPN)
  • 1 mic2981 High-Voltage High-Current Source Driver Array (Digikey part #576-1158-ND)
  • 8 3.3kohm 1/4 watt resistors for switching the driver array (Radio Shack part #271-1328)
  • 1 Atmel ATmega8 microcontroller (Mouser part #556-ATMEGA8-16PU)
  • 1 12MHz crystal for the microcontroller clock source (Mouser part #815-AB-12-B2)
  • 1 2200-hole prototyping board (Radio Shack part #276-147)
  • Converted ATX power supply: See This Instructable
  • Solid core 22-awg hook-up wire (Radio Shack part #278-1221)
  • Solderless breadboard (Radio Shack part #276-169 (no longer available, try: 276-002)
  • AVR Dragon (Mouser part #556-ATAVRDRAGON)
  • Dragon Rider 500 by Ecros Technologies: See This Instructable

Notes Regarding Parts


Row and Column Drivers: Probably the most difficult part of this project is picking the row and column drivers. First off, I do not think a standard 74HC595 shift register is a good idea here because they cannot handle the kind of current we want to send through the LEDs. This is why I chose the HEF4794 driver as it can easily sink the current present when all 8 leds are in one row are switched on.

The shift register is present on the low side (the ground pin of the leds). We will need a row driver that can source enough current to string multiple columns together. The mic2981 can supply up to 500mA. The only other part I have found that performs this task is the UDN2981 (digikey part #620-1120-ND) which is the same part by a different manufacturer. Please send me a message if you know of other high-side drivers that would work well in this application.

LED Matrix: This matrix is 8x8 because the row and column drivers each have 8 pins. A larger LED array may be built by stringing multiple matrices together and will be discussed in the "modular concepts" step. If you want a large array, order all of the needed parts at one time.

There are 8x8, 5x7 and 5x8 LED matrices available in one convenient package. These should be easy to substitute for a diy matrix. Ebay is a good source for these. Mouser has some 5x7 units available such as part #604-TA12-11GWA. I used cheap green LEDs because I'm just playing around and have fun. Spending more on high-brightness, high-efficiency LEDs can allow you to produce a much more spectacular looking display... this is good enough for me though!

Control Hardware: The matrix is controlled by an Atmel AVR microcontroller. You will need a programmer for this. Because I am prototyping I am using the Dragon Rider 500 for which I have written both assembly and usage instructables. This is an easy tool for prototyping and I highly recommend it.

« Previous StepDownload PDFView All StepsNext Step »
130 comments
1-40 of 130next »
Nov 30, 2011. 4:54 AM'earl says:
Should be "clamp" Just saying.
Oct 21, 2011. 4:08 AMeriknyquist says:
I want to build something like this but I've noticed that most of the examples of code that I've found for LED- driving programs are written in an assembly language. Is there a reason for that? would like to avoid it if possible...
Oct 17, 2011. 3:36 PMaxeman911 says:
how do u upload code in C++ to the arduino???
Oct 9, 2011. 11:43 PMkimchhour says:
hi sir.
Oct 9, 2011. 11:43 PMkimchhour says:
Hi sir i need to make board for matrix 8×32 .
Jul 11, 2011. 12:36 PMaxeman911 says:
instead of mic2981 would a decade counter work, or could we just out the pins directly on the arduino?
Jun 18, 2011. 6:30 AMavadhut10001 says:
Atmega16 ?code Help PLZ
Jan 9, 2011. 7:13 AMshanakaplus says:
I'm using cad-soft eagle software. I could not find hef4794 shift register . can you help me to find in eagle?
May 11, 2011. 6:30 PMavanner77 says:
or, if they dont match up, you can make your own part with this tutorial:
http://www.sparkfun.com/tutorials/110
May 9, 2011. 1:54 PMavanner77 says:
if you check the datasheets for the hef4794 and the 74hc595, you can see if they have the same pinout and just use the eagle part for the 595
Feb 23, 2011. 8:26 PMemihackr97 says:
hi, im really interested in this project, specially in the 16x16 array, but I want to use it with an arduino, and also, that each LED is individually addressable (meaning that the code shuld have a place with lines with the text "B00000000, x32" and that each line has a total of 256 0 (Which can be changed to 1 to make tle LED light up) so each line would be a new frame with every LED individually addressable.
The problem is that Im kinda new with microcontrollers and can't write the code, Where can I get it?? can you help me write it??
plz help,
really interested in ur project.
Thanks.
Feb 14, 2011. 10:50 AMsun580 says:
thanks its good
Jan 9, 2011. 1:00 AMkalasas18 says:

I have a simple ASM program with a matrix display light just columns. An example:

;-----------------------
LIST P=16F876
#include <p16F876.inc>

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
ORG 0x2100
DE 0x00
ORG 0


cblock 0x20
d1
d2
d3
endc

goto start

Delay
;999990 cycles
movlw 0x07
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0

;6 cycles
goto $+1
goto $+1
goto $+1

;4 cycles (including call)
return

loop:
movlw b'00000111'
movwf PORTA
movlw b'11110010'
movwf PORTB
movlw b'11111111'
movwf PORTC
call Delay
call Delay
call Delay

goto loop
start:
bsf STATUS,RP0 ; select register page 1
movlw 0 ; put 0 into W
movwf TRISC ; set portC all output
clrf TRISA
clrf TRISB

bsf STATUS,RP1 ; select Page 2,
bcf STATUS,RP0 ; by setting RP1 in Status register and clearing RP0

clrf PORTC ; select Digital I/O on port C


bcf STATUS,RP1 ; back to Register Page 0
goto loop

end
;-----------------------

This program code is OK. But I want the program to which I could display the words fleeing across the screen. Started, I tried to ignite a pair of columns on different sites but with the burning LEDs. But received some strange flashing, do not light longer ... Anybody know what's wrong ...
Programme code:

;-----------------------
LIST P=16F876
#include <p16F876.inc>

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
ORG 0x2100
DE 0x00
ORG 0


cblock 0x20
Delay1 ; delay loop 1
Delay2 ; delay loop 2
Delay3 ; delay loop 3
TimeDelay ; time delay x 0.001 s
EndCount ; used to tell PIC the end of the table is reached
Counter ; used as table counter
Line1 ; Line 1
Line2 ; Line 2
Line3 ; Line 3
Line4 ; Line 4
Line5 ; Line 5
sad
Line6 ; Line 6
Line7 ; Line 7
Line8 ; Line 8
Layer4 ; brightness, and time
Brightness ; LED brightness
Time ; time for each pattern to stay
Temp ; temp register
d1
d2
d3
endc


goto start

Delay
;999990 cycles
movlw 0x17
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0

;6 cycles
goto $+1
goto $+1
goto $+1

;4 cycles (including call)
return

loop:
movlw b'00000001'
movwf Line1
movlw b'11110010'
movwf Line2
call output



call Delay
movlw b'11100000'
movwf Line1
movlw b'10101010'
movwf Line2
call output
call Delay

goto loop


start:
bsf STATUS,RP0 ; select register page 1
movlw 0 ; put 0 into W
movwf TRISC ; set portC all output
clrf TRISA
clrf TRISB

bsf STATUS,RP1 ; select Page 2,
bcf STATUS,RP0 ; by setting RP1 in Status register and clearing RP0

clrf PORTC ; select Digital I/O on port C
bcf STATUS,RP1 ; back to Register Page 0
goto loop



output:
movfw Layer4
andlw b'00000001'
movwf Time
incf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1



clrf PORTB ; clear port B
movfw Line1 ; move layer1 to W
movwf PORTC ; put W onto PortC

bsf PORTB,4 ; turn on layer 1 buy outputing bit 5 of PortB

movfw Brightness ; put brightness into W
call Delayy ; call the delay

bcf PORTB,4 ; turn off layer 1

movfw Brightness ; put Brightness into W
sublw 4 ; sub W from 4
btfss STATUS,Z ; skip if the zero flag is set
call Delayy ; call the delay
decfsz Time

clrf PORTB ; clear port B
movfw Line2 ; move Line2 to W
movwf PORTC ; put W onto PortC

bsf PORTB,5 ; turn on layer 2 buy outputing bit 6 of PortB

movfw Brightness ; put brightness into W
call Delayy ; call the delay

bcf PORTB,5 ; turn off layer 2

movfw Brightness ; put Brightness into W
sublw 4 ; sub W from 4
btfss STATUS,Z ; skip if the zero flag is set
call Delayy ; call the delay
decfsz Time

decfsz Time ; decrement the Time regiester
return


Delayy:
movwf Delay3 ; put W into Delay 3

Loop1:
; After Delay2 decreses to 0, it is reset to..
movlw 0x1 ; put 1 into W
movwf Delay2 ; put W into Delay2

Loop2:
; After Delay1 decreses to 0, it is reset to E9h
movlw 0x1D ; put 80 into W
movwf Delay1 ; put W into Delay1

Loop3:
decfsz Delay1 ; decrement Delay1
goto Loop3 ; jump back to Loop3
decfsz Delay2 ; decrement Delay2
goto Loop2 ; jump back to Loop2
decfsz Delay3 ; decrement Delay3
goto Loop1 ; jump back to Loop1
return

end
;----------------------------------------------------------

Thanks for help. :)
Nov 12, 2010. 11:07 PMca.le says:
Does anyone know if the matrix would work with an Arduino board????
Oct 5, 2010. 5:27 AMji394su3 says:
good article!!
Sep 3, 2010. 2:48 AMpavanbhushan says:
what is the additional connection that should be made to make the LEDs glow individual letters???
Sep 3, 2010. 2:47 AMpavanbhushan says:
how can we make the 8*8 led display the letters???? I'm stuck at this point...
Aug 3, 2010. 12:45 AMSuresh.D.M says:
can we add shift registers to the column and shift the bit
Jul 15, 2010. 2:30 AMpontikakis3 says:
Where is the Font Set at http://en.radzio.dxp.pl/ks0108/ ?? Anthony
Oct 9, 2009. 4:10 PMDanielIt says:
Hey there..nice project,easy to acomplish and lot of stuff to learn.Now that i am learning C,i enlarged the project to be 8x32 columns,but i cant get the code to work.Any hints where are the parts that needs to be worked?There are some parts in the code commented that need to be altered,but i cant figure out how.If you can jelp pls send me an PM,or ust reply here.
Thank's and keep up the good work!!
Jun 1, 2010. 4:57 AMdhimullai says:
Hi;
I too tried with expanding 8x32 , it doesn't works as expected., Any one can help me,
Apr 24, 2010. 11:54 AMknektek says:
Could you use a whole load of transistors? For switching something else? Maybe an array of motors or switching relays?
Feb 28, 2010. 6:20 AMgreekwow says:
does the leds have good brighness? there is not problem with duty cycle? becouse i have that problem in my project, (i use 4017 decade counter)
Feb 21, 2010. 11:27 AMndinitz says:
 can this be done using parallel load shift registers or does it have to be done with serial load.

if it is to be doable with parallel load registers then the board doesnt have to display only one column at a time, right? that would be so much cooler and you could build modules and connect them with parallel in serial out to serial in parallel out.

leme know what you think...
Jan 17, 2010. 5:51 AMrammbo69 says:
Both are 20 pF.
Sep 29, 2009. 1:25 AMmalth91 says:
a very informative and interesting site
Sep 16, 2009. 2:32 AMroketlights says:
what are values for c2 and c3 ????? im relying entirely on this!! please? i got everything but this part and the programing part. please help!!!
Aug 27, 2009. 8:46 PMjeff-o says:
Just to clarify, could I program in a bunch of phrases (like, 30-40) and call up any one of them based on certain inputs? What is the limit on phrase length without any external memory?
Aug 25, 2009. 12:55 AMroketlights says:
i just bought a butt load of registers. im trying to make a 32 x 32 any pointers? on how to connect 8x8 in rows and columns? any help would be apprecieated. :)
Jul 23, 2009. 5:06 AMhype1 says:
I am looking into your setup and I noticed this: Why do you use such a driver on the high-side when you are lighting one column at the time during multiplexing? Now you could source rows of 8 LED's at one time, but that isn't the case while multiplexing, right?
May 26, 2009. 9:22 AMmonkeydluffy says:
bro barney, can u help me to get HEF4794? i need the HEF4794?? 9 of them to controll my Solar Display. In my country there's no store sell that shift register :( :( Can I get it from u?? I'll pay it later. I'm in Jakarta, Indonesia. Please help me master, this is for my graduation project. thank you very much :)
Apr 13, 2009. 5:34 AMmonkeydluffy says:
(removed by author or community request)
Apr 15, 2009. 6:21 PMmerseyless says:
u just posted your email on the internet! prepare for spam...
May 21, 2009. 10:51 AManimaster says:
he has misspelled his email ;) i think it has to be GMAIL
Apr 23, 2009. 7:55 PMReCreate says:
Eh...ahaha!
Apr 23, 2009. 7:15 PMSagar Gondaliya says:
its probably one he made for just this purpose.
May 8, 2009. 6:02 AMndegwa says:
I need help programming the micro controller could you please help i would like my display to scroll the following NBI..............VOI.............MBS over and over and can also be made to stop at one of the letters shown.
Feb 14, 2009. 1:27 PMuberdum05 says:
Could you use a MAX232 to connect it to a computer?
Apr 30, 2009. 5:43 AMEricTheRed16 says:
Im trying to get mine working from the COM port, so I am using a MAX232 to convert the data from -3V - 3V to 0V - 5V, then feeding it into a UART (ST16C1450) to get my 8 outputs. I havent had much any luck yet with it yet, as I'm still learning as I go. Right now I'm waiting on new caps for the uart.
Apr 26, 2009. 6:59 AMndegwa says:
Hi nice idea i was hoping to use this idea but enlarge the font characters where i could use four LEDs in place one LED is that possible
1-40 of 130next »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
37
Followers
6
Author:barney_1