Need help with LED clock - new to Arduino

hi, I am new to this forum, and have no previous experience with the Arduino Nano. I do have some electronics knowledge from building kits, and designing some simple projects. This project, however, is somethimg new to me; using a microcontroller for the first time.

The clock I am building uses a array of LEDs 3 x 18 (3 LEDs per column and 18 per row). The columns are cathode and the rows are anode. The LEDs are 3mm white, 3.2V and 20 mAh. I have the array built, but need help with hooking it up to a Nano. Is it possible to use the pins on the Nano, or will I need shift registers? Which type is best for this project, and what other components would I need?

The array is divided up into six groups of 3x3 LEDs, each representing a character in the display for hours, minutes and seconds. The full array is actually 5 x 18, but the fourth and fifth rows of each character stay lit, so I hooked them together separately.

The entire circuit will be running on 5V, so as to simplify it somewhat. I would like it to display time in 12 hour format, no AM-PM indicator, and no scrolling of the characters

I have attached pictures of the array that I have built so far ( the LED leads on the back of the display are reversed from the schematic since the front of the array isn't visible). The 0 to 9 characters are of the full display. Any help would be greatly appreciated.

attached pictures show here for easy viewing without download

You can use the pins on the Nano with some resistors, using multiplexing. and store your 0 to 9 characters in array.

Each LED draws 20 mA (from your description). That is basically the maximum of a pin on an Arduino. So you can only have one LED on at a time.

If you make line X0 high, you can only activate one of the LEDs on Y0 .. Y17 at a time by making that line low.
The same applies to most of the Y lines. If you activate Y0 by making it low, you can only activate X0 or X1 or X2 at the same time by making it high.

As said above, you can multiplex and make sure that only one LED is on at a time.

You need 21 pins for the display. The Nano has 22 data pins (if I counted correctly). If you have 21 pins in use for the LEDs, have you considered how you are going to set / adjust the time once it is running? You have one pin left for a button; you will have fun programming that to be usable for a 'user interface' (probably not undoable but definitely a very nice challenge).

My conclusion is that shift registers (or SPI / I2C port expanders), possibly in combination with some additional hardware to meet the current requirements, are the way to go. I can not advise on the required hardware :frowning: Do a search on the web.

Sorry, I forgot to mention that I also have a DS3231 Real Time Clock Module. I wasn't sure that the pins on the Nano would be sufficient, which was why I also asked about shift registers. I have looked on the Internet, but there is so much different information for different clock projects, that I wasn't sure which one would be right for my design. As far as I could tell, no one else has designed an array this size; either larger, or with ready-made modules. I originally considered that option, but could not find any suitable for my design. The entire display is custom-built so the pixels would be rectangular rather than square.

I really appreciate your response, but as I stated, I am new to microcontrollers, so it looks like the shift register is probably the way to go.

If you could provide some help with what I need to program the Nano when I manage to finish the clock circuit, that would be great. Again, there is so much information to look through, any tips would really help.

As you already use a I2C device, you can use a I2C port expanders like MCP23017. You will still need some drivers (transistors, fets, ...) and resistors.

Somebody else may come along with a total solution.

Hello,

So the challenge is to drive the leds with just the Nano and minimal other components?

To minimise the number of Arduino outputs, you need to make your matrix as square as possible, electrically speaking. Can you cut those red wires? If so, you can make your matrix into a 6x9 array. This would require 15 Arduino outputs. That uses up every last one available on the Nano, because you can't use digital 0 & 1 (serial lines), or analog 4 & 5 (i2c bus), or analog 6 & 7 (input only). If you need extra buttons for setting the time, you could put these in a resistor ladder attached to analog 6 or 7. You would also need 6 npn transistors for the cathode columns.

Paul

As in reply #6, except I would suggest using a MAX7219 to drive the array.

aarg:
I would suggest using a MAX7219 to drive the array.

I thought about that too, and ht16k33. But i could not think of a neat way to connect either to the OP's matrix.

In response to post #6; how would I rewire the array to make it 6 x 9? And how would I address the LEDs to create the same layout on the display?

I mentioned in my original post that I have some electronics knowledge, but I have never heard of a resistor ladder, so I wouldn't know how to make one.

I see that the best way to go is with shift registers to minimize the number of pins used on the Nano so I could add the time setting buttons. Unless if it is possible to use both the nano pins and a shift register (Nano pins for the '9' in the array and the shift register for the '6', as there are only eight outputs on a shift register).

That still leaves me with the problem of how to hook up these components to the Nano, and what value resistors or any other extra components that would be needed as well.

To post #7; I have come across mention of a shift register that can handle higher loads. It is called a TPIC6B595N, and it seems to incorporate the characteristics of a shift register and a transistor array in one package. Would this work, as well as cut down on the number of components needed?

I really appreciate the input I have received so far, and hope that it and any other input will lead to a solution to my problem.

jeredneus:
In response to post #6; how would I rewire the array to make it 6 x 9? And how would I address the LEDs to create the same layout on the display?

I'll whip up a schematic for you. Give me a little time.

jeredneus:
I mentioned in my original post that I have some electronics knowledge, but I have never heard of a resistor ladder, so I wouldn't know how to make one.

"Ladder" may not be the correct term. Look at this.

jeredneus:
To post #7; I have come across mention of a shift register that can handle higher loads. It is called a TPIC6B595N, and it seems to incorporate the characteristics of a shift register and a transistor array in one package. Would this work, as well as cut down on the number of components needed?

Yes. You would still need series resistors for the leds, and perhaps 3 shift registers.

6x9 matrix like this:

That looks great! Thanks so much.

As I mentioned before, is it possible to use both a shift register and the the pins on the Nano so I would only need one shift register? I'm trying to keep it as simple as possible.

jeredneus:
As I mentioned before, is it possible to use both a shift register and the the pins on the Nano so I would only need one shift register? I'm trying to keep it as simple as possible.

Yes, you could use the tpic chip you mentioned, to replace the 6 transistors in my schematic. The tpic6c595 or tpic6d595 should be adequate for this job, no need to use the higher current tpic6b595, unless it's cheaper.

I checked on eBay, and the tpic6c595 is more expensive than the tpic6b595, and the tpic6d595 did not come up at all in the search, only the tpic6b595 was listed instead.

So I can connect the anode rows directly to the Nano, and the cathode columns to the shift register? If so, then do I need to terminate the two remaining pins on the shift register so they are not 'floating' I believe the term is?

jeredneus:
I checked on eBay, and the tpic6c595 is more expensive than the tpic6b595, and the tpic6d595 did not come up at all in the search, only the tpic6b595 was listed instead.

Fine, buy that!

jeredneus:
So I can connect the anode rows directly to the Nano, and the cathode columns to the shift register?

Yes

jeredneus:
If so, then do I need to terminate the two remaining pins on the shift register so they are not 'floating' I believe the term is?

No. Floating outputs are not normally a problem. Floating inputs can be.

One final question, and I believe I will have the display completed. After originally asking about the changes needed to the array to make it a 6 X 9 grid, I played around with the schematic I originally created, and came up with this design before I saw yours.

Please let me know if it is usable, or if I'm on the wrong track. Picture 1 is of the actual layout of the LEDs, and Picture 2 is a representation what it would look like if built in a physical 6 X 9 array. The transistors (or shift register) would connect to the cathode pins at the top of the array.

Thank you for the time you have taken to help me with this project.

These both look equivalent to my schematic, yes.



P.S. in case you are still confused, "mA" is a measure of current. "mAh" is a measure of charge, energy or battery capacity. If a current of 1mA flows for 1 hour, that is 1mAh.

PaulRB:
I thought about that too, and ht16k33. But i could not think of a neat way to connect either to the OP's matrix.

Neat, as in assigning outputs to segments/digits? I had that problem with a unique LCD display module, and I solved it by just creating a look up table. It might transgress elegance, but it worked.

aarg:
Neat, as in assigning outputs to segments/digits?

Exactly. The OP's matrix was either 3 anodes and 18 cathodes, or 9 anodes and 6 cathodes. max7219 has 8 anodes and 8 cathodes. Any way you wire it, its going to be a bit of a bugger.
ht16k33 has 16 anodes and 8 cathodes. That would work, but seems a bit of a waste.