Arduino

Serially Interfaced, 8-Digit, 7-Segment, LED Display for Arduino

DSCN2761

In a lot of your electronics projects you may need a display to provide information to your users.  These days the project builder has a plethora of options to consider when deciding on a display.  The needs of the project will dictate to some degree what technologies suit. 

The first thing to consider is what types of data you wish to display, do you wish graphical, text or will a numeric display suffice?  Next we must think about the look of the display and the readability.   Different technologies (i.e. OLED, LED, LCD, OMED) all have their own visual signatures and limits and benefits.

This project uses 7-Segment common cathode numeric LED (Light Emitting Diode) displays.  The 7 segment display has been around for years and gives projects a cool retro look.  Readability is very good from this technology and displays are available in a multitude of sizes.  So for projects that need to be read at a distance this is a very scale-able option.  Thanks to the Maxim MAX7221 IC (Integrated Circuit) it is also very easy to control these LED displays using a microcontroller such as the AVR processor within an Arduino.

The display that I have put together is for developmental purposes to be used when experimenting with my Arduino.  As such as I was not overly worried about my choice of 7-segment LEDs though I found pretty nice ones on E-bay.  Colours commonly available for these displays are red, green, yellow, blue and white.  I opted for  single digit 0.8’ tall blue displays.

single 7seg ledSingle digit 7 segment display normally have 10 pins.  7 which control each of the segments, 1 to control the decimal point and two (internally linked pins) which are either the common anode (positive connection) or common cathode (negative or Ground connections) depending on the display type.  The best way to think about these units are just a bunch of standard LEDs all in a box together their connections tied together at one end and left separate at the other.

It is possible to operate 7 Segment display directly using a microcontroller but it is not the most practical way of doing things simply because of the number of outputs required to drive the LEDs.  Each display requires at least 8 pins.  Now to make a useful display you are going to need a few of these led displays placed together.. That’s a lot of pins!  Normally when we use LEDs we also require a current limiting resistor on each pin to control the brightness of each separate segment and also prevent the LEDs from burning out.  So that is also a lot of resistors as well!

Luckily there are techniques we can use to reduce the number of pins our led displays are going to need.  One which is called multiplexing can help a lot.  Multiplexing is where as well as attaching each of the segment pins of the LED display to a micro-controller, we also attach each of the common cathode (or anode) pins to the microcontroller’s pins.  By switching pairs of the micro-controller’s pins together we can reduce the number of pins required yet still light every segment of our multiple displays.  The clever trick is that by switching the LEDs on and off quickly we can make it appear as if several displays are all on at the same time even though they are really flickering.  So the same pins can control several displays… we are still talking about a lot of pins being used though!

Step forward the Maxim MAX7221 or MAX7219 Serially Interfaced, 8-Digit, LED Display Drivers.  These dedicated IC’s are designed to drive common cathode 7 segment LED displays.  This “chip” attaches to your microcontroller (in my case Arduino board) and handle all the difficult control of the LED displays.  Being serially controlled, the Arduino only needs to use 3 of its data pins to talk to the Maxim made chip, and as it does the hard work, the Arduino is hardly taxed at all.  The Maxim chips can control 8 LED displays per chip and several chips can be used together to gain more if needed.

MAX7219, MAX7221: Typical Application CircuitFor Arduino experimenters the MAX7221 or MAX7219 ICs (the MAX7221 is the lower electrical noise version) are ideal drivers for a LED display for several reasons:

Firstly either the MAX7221 or MAX7219 are available in easy to solder DIP (Dual Inline Package)form, so no fiddly surface mount soldering is required.

Secondly either IC (MAX7221 or MAX7219) are already supported with dedicated Libraries.  So programming the Arduino to control them is relatively easy.

Thirdly, the Maxim IC’s handle the current supply each of the LED segments, so no need for lots of separate resistors, one is all that is required to set the brightness.

Fourth, this leaves plenty of pins on your Arduino to attach other goodies.

Fifth,the Maxim ICs do all your multiplexing, so they don’t use up too much of your Arduino’s limited brain power.

stripboardFor my prototype display I decided to use 8 7-segment  LED displays, the maximum the MAX7221 can handle.  It is no problem if you need less, but I wanted my prototyping module to be as big/flexable as possible.  I used stripboard to build the prototype as it is easy and cheap.  The particular board I used was Maplin Electronics 213 x 38mm Stripboard and it was ideal for this prototype.  with 81 rows split in the middle it suited this down to the ground.

DSCN2737In order to keep things as neat as possible, I used CAT5 cable to do the wiring on the board and as you can see there is lots of it.  I laid as much as is possible down before soldering the LED displays in last.  Wiring is all done according to the examples on the datasheet from Maxim.  Basically all the pins that control segment A are joined together, same for segment B, C etc. These then attach to the IC’s respective pins.  The common Cathode for each display also have a pin each to connect to on the Maxim IC.

DSCN2743

The only other components required on the module were a couple of capacitors (10uf and .22uf between the 5v connection and ground and the previously mentioned resistor (I used 22K 1/4w here, adjust as necessary, with help from the datasheet, for your own display) to set the current to the LED segments.

The 5v, GND, DIN, Load and CLK pins were attached to loose wire for connection to my Arduino.  I heat-shrinked this into a loom to keep things neat.

DSCN2748

Getting the display working with the Arduino turned out to be fairly easy.  I used a ScrewShield (available form most Arduino suppliers) to connect Load, CLK and DIN to pins  10, 11 and 12 or the Arduino. An example sketch is included with the Arduino software.

So far I have created successfully a countdown timer and a basic clock in combination with my DS1307 RTC based Shield.  Both use the ledcontrol library included in later versions of the Arduino software.

If you are intending making one of these modules for your own experiments I would recommend reading This article from the Arduino Playground.