Controlling 7-Segment LED's?

Hi,

I'm trying to drive a set of 4 individual 7-segment LED's to display the time. I've found that there are multiple ways to do this including using a MAX7219 (serial in/out drivers), 74HC4511 (BCD to 7-Segment decoder) or using shift registers like the 74HC595. I wanted to multiplex the displays so that I can reduce current draw.

Which of these are the simplest to work with in the Arduino environment? Any other recommendations?

Thanks! :)

Dead simple. Go for the MAX7219.

Or buy one of these: |500x500 It's cheaper than anything else you will find.

What - too many digits? You don't have to use them all (you could pull off one half), but - think of extra functions - such as "=" for the colon, spinners and display seconds.

Thanks for the response!

Ok, I'll have a further look into the MAX7219's datasheet. However, isn't there inherently much more programming overhead required in that sort of driver? When would it be advisable to use the other options?

Thanks again :)

No. You program 5 control registers in setup(). Then in loop you write to 1 of 8 data registers to update a display. Pretty simple. Use SPI.transfer to do it quickly

digitalWrite (csPin, LOW);
SPI.transfer(addressRegister); // 1 to 8
SPI.transfer (dataToDisplay);
digitalWrite (csPin, HIGH);

Thanks for the response!

Is there a tutorial which explains that method further? Also, could you explain "register" in this context? Is it just an array of bytes which are stored for later use?

Additionally, is it generally recommended to use libraries such as LedControl for the MAX7219?

Thanks again

Just the tutorial called the Datasheet.
See Table 2 for the register addresses. Write to the bottom 5 in setup(), then leave them alone except for maybe intensity if your sketch is changing brightness of the attached LEDs.
Setup SPI with the default settings.
#include <SPI.h> goes at the top of your sketch
byte csPin = 10;
in setup:
pinMode (csPin, OUTPUT);
SPI.begin();
then load the 5 registers per the code example I gave above.

In loop, write to registers 1 to 8 with the data you want displayed. If using 0,1,2,3,4,5,6,7,8,9, H,E,L,P, -, blank, you can use Decode Mode and just the data per Table 5.

No library needed, just a little reading of the datasheet.

Register, 8 bits that data is written into. Just like any other register.
I don’t use any library for MAX7219 because the ones I have seen do not use the SPI port of the 328P chip for fast transfers out to the chip, and instead bit-bang the control lines out on other pins.

MAX7219-MAX7221.pdf (451 KB)

And as a young man always says, if you are using a 7219 chip don’t forget to add decoupling to the power pins (19-4).
.

Two caps, 10uF and 0.1uF
“To minimize power-supply ripple due to the peak digit
driver currents, connect a 10μF electrolytic and a 0.1μF
ceramic capacitor between V+ and GND as close to
the device as possible.”

Although the modules I have recommended incorporate the bypassing - at least "C1" - the 0.1 µF is fitted; the position for the electrolytic "C2" which would be about 10 µF is vacant. I just dug one out to check. :grinning:

You also want to bypass D1 on these modules - it is an unnecessary and somewhat offensive presupposition that the user is so dumb as to require input polarity protection (but on this module only? :astonished: ) and will foul up matters if more than one module is chained.

Paul__B: Although the modules I have recommended incorporate the bypassing - at least "C1" - the 0.1 µF is fitted; the position for the electrolytic "C2" which would be about 10 µF is vacant. I just dug one out to check. :grinning:

You also want to bypass D1 on these modules - it is an unnecessary and somewhat offensive presupposition that the user is so dumb as to require input polarity protection (but on this module only? :astonished: ) and will foul up matters if more than one module is chained.

I qualified this by saying if you were using a 7219 chip. Nice to see the ready made version uses a cap thou.

LarryD: I qualified this by saying if you were using a 7219 chip.

It actually does not matter whether you use a MAX7219 in this respect, or something else, does it?

LarryD: Nice to see the ready made version uses a cap thou.

Well, the 0.1 µF at least. Further inspection of the images for the module I cited - which would be completely typical - demonstrate that "C2" is missing and in fact unlike the one I am looking at here, the displays are soldered directly in and not socketed so there is no room for C2 above board, though you could fit it underneath. I think I have some SMD "chip" electrolytics that would suit.

The situation is similar for the 8 by 8 matrix modules. The older, crude design includes the 10 µF capacitor, the compact and stackable SMD version does not.

It actually does not matter whether you use a MAX7219 in this respect, or something else, does it?

No. Didn't understand the word "Although". What did you say about obsessive? ;) .

LarryD:
Didn’t understand the word “Although”.

I had some trouble with that word, but decided to leave it with two meanings, a sort of technical double entendre.

  • Although you do need the bypasses, the modules (attempt to) provide them.
  • Although they provide the bypasses, they don’t necessarily provide all of them! Unpopulated board position for the electrolytic. (No position provided for this on the compact and stackable SMD version of the 8 by 8 matrix module.)

LarryD:
What did you say about obsessive? :wink:

I said it helps, or is essential for my day job. :grinning:

Can’t deny it.

fghfghdfghtrdhdtrf: Any other recommendations?

Not simplest or easiest or best, but you might find this interesting!