Multiplexing with Arduino and the 74HC595 by amandaghassaei
Featured
multiplex thumb.jpg
FKCG4RPH1ZG7675.jpg
led matrix_schem.jpg
labeled schem.jpg
The 74HC595 is an easy and inexpensive (at about 60 cents apiece) way to increase the number of digital out pins on your Arduino.  In this tutorial I'll show you how to drive up to 16 LEDs with one 74HC595 using a technique called multiplexing.  In the end, all 16 LEDs will require only three of the Arduino's available digital pins.

The finished product will look like this:


I used the sparkfun button pad pcb to build my 4x4 led matrix because this is the first step in a longer project I'm working on that involves backlit buttons.  However, you can build your own 4x4 led matrix pretty easily on a breadboard, and I'll provide schematics that will show how to do that.  My parts list is given below:


Parts List:

SPARKFUN:
(1x) Button Pad 4x4 - LED Compatible Sparkfun COM-07835
(1x) Button Pad 4x4 - Breakout PCB Sparkfun COM-08033
(1x) Arduino Uno Sparkfun DEV-11021

DIGIKEY (you could find these at Jameco):
(16x) White 5mm LED (3mm is fine too) Digikey C513A-WSN-CV0Y0151-ND
(1x) 74HC595 shift register Digikey 296-1600-5-ND
(1x) 16 pin IC socket Digikey A100206-ND

JAMECO:
(1x) 16 conductor ribbon cable Jameco 28RC16-10VP
(1x) 16 pin right angle connector Jameco 746285-3
(2x) male header pins Jameco 7000-1X40SG-R

Additional Materials:
22 Gauge Wire, multiple colors Radioshack #278-1221
protoboard with copper Radioshack #276-147
wire cutters
wire strippers
solder
 
Remove these adsRemove these ads by Signing Up

Step 1: What Is Multiplexing?

multiplex1.gif
multiplex2.gif
Multiplexing is a very efficient technique for controlling many components wired together in a matrix/array.  In this example, I'll be talking exclusively about multiplexing an array of LEDs, but the same basic principles apply to other multiplexed components (sensors, buttons, etc).

In a multiplexed array of LEDs, only one row of LEDs is on at any given time.  It seems like this would limit the types of shapes we can display on the LED matrix, but it actually doesn't.  This is because the arduino (or whatever is sending data to the array) is switching through each row so quickly (hundreds or thousands of times a second) that we do not perceive the flashing on and off of each consecutive row.  You can read more about this phenomenon, called persistence of vision, on wikipedia.

So how do we send data to one row at a time?  If we connect five volts (red) to one row and connect ground (blue) to the other three rows and cycle through each row one by one, it will look something like figure 1.  Now image that while one of the rows is at +5, we connect one of the columns to ground.  As shown in figure 2, this will cause the LED at the junction of the +5 row and GND column to light up.  This way, we can address each of the 16 LEDs in the matrix individually using only eight leads (four to the rows and four to the columns).

Now look at the image below.  Imagine if we very quickly turn on the LED in the upper left corner (position 1,1), then the LED at (2,2), then (3,3) and (4,4), and we cycle between these four LEDs very quickly (hundreds of times a second).  It will appear that all four of these LEDs are on a the same time (as shown in right image in the image below).  Study the diagram below and convince yourself that this is true.


ignatiusD says: Nov 15, 2012. 6:12 PM
Hi, I've been reading about muxing and things, and the title of this instructable is kind of confusing to me because if I'm not mistaken you're using a shift register, not a multiplexer. Is there not a significant difference?
amandaghassaei (author) says: Mar 28, 2013. 10:55 PM
the terminology is kind of ambiguous, a shift register implies something digital, like the chip I'm using. Multiplexing in general is this technique of controlling an array, a multiplexor is something that does the multiplexing. often people refer to analog chips as mux/demux and digital as shift registers, but they both do multiplexing.
TAGAPAW says: Mar 13, 2013. 8:28 PM
Hi It's really Nice Instructables, but can this method to light up up to 120 button simultaneously , thank you very much
amandaghassaei (author) says: Mar 28, 2013. 10:53 PM
yes, definitely.
Fuzzy-Wobble says: Aug 4, 2012. 6:08 PM
Great Instructable!
One this I am a bit confused about. What is you want to light more than one LED at once.
Wouldn't this cause some other lights to illuminate unexpectedly using this method?
amandaghassaei (author) says: Aug 4, 2012. 7:26 PM
no you can control exactly which leds you want to light. In step 13 I show how you can address each led in the matrix. You can light up many at the same time with no problem.
francisroan says: Jun 8, 2012. 3:07 AM
could ya make a video of the finished project
amandaghassaei (author) says: Jun 8, 2012. 8:03 AM
I will, but I'm still working on it. it's going to be a fancier version of this.
Jayefuu says: Jun 6, 2012. 1:05 PM
Nice work! This is very complete :)
amandaghassaei (author) says: Jun 6, 2012. 2:32 PM
thanks!
gregoryfenton says: Jun 6, 2012. 11:05 AM
Favourited, I just happen to have a large bag of LEDs and a bunch of 595s.
megaduty says: Jun 6, 2012. 10:27 AM
Fave'd this and will be using later in a project; thanks for the ible!
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!