LED matrix using shift registers

 by barney_1
FeaturedContest Winner
10 - 64 LEDs in place.JPG
13 - 8x8 Box and Circle.JPG
LED-matrix-using-shift-registers_Tech.Jpg
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 1: Parts

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.

1-40 of 134Next »
MCUman says: Apr 4, 2013. 8:08 PM
I recently saw this written up in EDN. It begs two questions. Is the latch really needed? What is the cost of this HEF4794? Given the POV of the human eye versus the speed of a microcontroller, I have never seen this as a problem using a old trusty 74HC164, which, BTW, drives LEDS very nicely. The cost of the HC164 is considerably cheaper over the cost of the 4794 by $2.00. How do I know this? I've used the HC164 in this mode for numerous successful designs that have gone to production, from toys to medical devices. This a great article to demonstrate to the HEF4794 but is it truly practical?
JHSTUBA says: Mar 20, 2013. 4:30 PM
Is the 10k resistor nescessary?
Kamilon says: Feb 22, 2013. 10:53 PM
I've been working on a very large LED matrix myself. If anyone wants to see a matrix that allows for direct drive (each LED individually controlled), check this out:

http://blog.kamilon.com/?page_id=114

Well done on this tutorial. You can create a small matrix for much cheaper than buying one by following your instructions.
jigs859 says: Feb 23, 2012. 10:46 AM
i m doing this project....but addition in this, i m use a gsm module which receives the message send by any cell phone, and it display the message on the led display...so i need CIRCUIT DIAGRAM and CODE for this project....plz help me soon...
samwhiteUK in reply to jigs859Sep 26, 2012. 3:57 AM
Basically you want someone else to do your project for you then don't you? You'll learn a lot more by doing the research and the graft yourself.
'earl says: Nov 30, 2011. 4:54 AM
Should be "clamp" Just saying.
eriknyquist says: Oct 21, 2011. 4:08 AM
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...
axeman911 says: Oct 17, 2011. 3:36 PM
how do u upload code in C++ to the arduino???
kimchhour says: Oct 9, 2011. 11:43 PM
Hi sir i need to make board for matrix 8×32 .
axeman911 says: Jul 11, 2011. 12:36 PM
instead of mic2981 would a decade counter work, or could we just out the pins directly on the arduino?
Avadhut.Deshmukh says: Jun 18, 2011. 6:30 AM
Atmega16 ?code Help PLZ
shanakaplus says: Jan 9, 2011. 7:13 AM
I'm using cad-soft eagle software. I could not find hef4794 shift register . can you help me to find in eagle?
avanner77 in reply to shanakaplusMay 11, 2011. 6:30 PM
or, if they dont match up, you can make your own part with this tutorial:
http://www.sparkfun.com/tutorials/110
avanner77 in reply to shanakaplusMay 9, 2011. 1:54 PM
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
emihackr97 says: Feb 23, 2011. 8:26 PM
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.
sun580 says: Feb 14, 2011. 10:50 AM
thanks its good
kalasas18 says: Jan 9, 2011. 1:00 AM

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. :)
ca.le says: Nov 12, 2010. 11:07 PM
Does anyone know if the matrix would work with an Arduino board????
ji394su3 says: Oct 5, 2010. 5:27 AM
good article!!
pavanbhushan says: Sep 3, 2010. 2:48 AM
what is the additional connection that should be made to make the LEDs glow individual letters???
pavanbhushan says: Sep 3, 2010. 2:47 AM
how can we make the 8*8 led display the letters???? I'm stuck at this point...
Suresh.D.M says: Aug 3, 2010. 12:45 AM
can we add shift registers to the column and shift the bit
pontikakis3 says: Jul 15, 2010. 2:30 AM
Where is the Font Set at http://en.radzio.dxp.pl/ks0108/ ?? Anthony
DanielIt says: Oct 9, 2009. 4:10 PM
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!!
dhimullai in reply to DanielItJun 1, 2010. 4:57 AM
Hi;
I too tried with expanding 8x32 , it doesn't works as expected., Any one can help me,
knektek says: Apr 24, 2010. 11:54 AM
Could you use a whole load of transistors? For switching something else? Maybe an array of motors or switching relays?
greekwow says: Feb 28, 2010. 6:20 AM
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)
ndinitz says: Feb 21, 2010. 11:27 AM
 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...
rammbo69 says: Jan 17, 2010. 5:51 AM
Both are 20 pF.
malth91 says: Sep 29, 2009. 1:25 AM
a very informative and interesting site
roketlights says: Sep 16, 2009. 2:32 AM
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!!!
jeff-o says: Aug 27, 2009. 8:46 PM
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?
roketlights says: Aug 25, 2009. 12:55 AM
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. :)
hype1 says: Jul 23, 2009. 5:06 AM
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?
monkeydluffy says: May 26, 2009. 9:22 AM
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 :)
monkeydluffy says: Apr 13, 2009. 5:34 AM
(removed by author or community request)
merseyless in reply to monkeydluffyApr 15, 2009. 6:21 PM
u just posted your email on the internet! prepare for spam...
animaster in reply to merseylessMay 21, 2009. 10:51 AM
he has misspelled his email ;) i think it has to be GMAIL
ReCreate in reply to merseylessApr 23, 2009. 7:55 PM
Eh...ahaha!
Sagar Gondaliya in reply to merseylessApr 23, 2009. 7:15 PM
its probably one he made for just this purpose.
1-40 of 134Next »
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!