Arduino LED Clock

Hey,
I’m new at Arduino and plan on building a LED clock running on Arduino. Could someone please guide me to the process on building it. I got the basic idea of programming in Arduino and got decent experience in C/C++. I understood the code for blinking LEDs but if i want the LEDs to increment their position as hour is incremented and i’m stuck, how do i make only certain leds to increment their positions which is connected to a single port on the Adruino uno. I’m a Computer Science student and pretty weak at electronics hence the trouble :P. Thank you in advance.
Attached image is the general idea of the LED clock… Hours in the inner circle lit up by leds on a stencil, Minute on the extreme and days in the intermediate. Thank you :slight_smile:

Untitled.png

Start by looking at shift registers. A good start is here: http://www.gammon.com.au/forum/?id=11518

How many LEDs total and in each ring? If the total is over around 8 you will need to multiplex. There are many ways to multiplex LEDs. Shift registers are a popular method and there are a lot of tutorials on using them.

groundfungus: How many LEDs total and in each ring? If the total is over around 8 you will need to multiplex. There are many ways to multiplex LEDs. Shift registers are a popular method and there are a lot of tutorials on using them.

The hour part got 12 LEDs and the Minutes is 60 LEDs :P . How do I code the arduino to increment the hour position if its connected to single Port on the arduino uno?

79 mono-color LEDs? Use max7219 (basically 8 shift registers in one package) to drive 64 LEDs, add 2 shift register for the last 8 and the 7 days. Or 5 WS2803 with 18 outputs, have 8 bits of brightness control per output. Or 79 WS2812 daisy chained, for RGB color at each location. Or ... The time & day tracking part is pretty straightforward.

CrossRoads: 79 mono-color LEDs? Use max7219 (basically 8 shift registers in one package) to drive 64 LEDs, add 2 shift register for the last 8 and the 7 days. Or 5 WS2803 with 18 outputs, have 8 bits of brightness control per output. Or 79 WS2812 daisy chained, for RGB color at each location. Or ... The time & day tracking part is pretty straightforward.

Thanks for the input, now actually looking into shift registers and how it works for arduino :P

Pretty bascic - using SPI.transfer to send data out. For MAX7219: chip select low send register address send data chip select high

digitalWrite (csPin, LOW);
SPI.transfer(registerAddress); // 1 to 8 display data, 9 to 15 for control registers (usually used only in setup)
SPI.transfer(data); // for display data, have an array to hold the data
digitalWrite (csPin, HIGH);

for daisy chained, shift registers, say you had 2: latch low send data send data latch high

digitalWrite (latchPin, LOW);
SPI.transfer(byte0);
SPI.transfer(byte1);
digitalWrite (latchPin, HIGH); // data outputs change on this rising edge

D13/SCK connects to '595 SRCLK D11/MOSI connects to 1st device SER IN D10/SS (latchPin) connects to RCLK '595 OE connects to Gnd, or a PWM output for brightness control '595 SRCLR connects to +5

(Why does the forum but those huge gaps in there? Odd.)

CrossRoads: Pretty bascic - using SPI.transfer to send data out. For MAX7219: chip select low send register address send data chip select high

digitalWrite (csPin, LOW);
SPI.transfer(registerAddress); // 1 to 8 display data, 9 to 15 for control registers (usually used only in setup)
SPI.transfer(data); // for display data, have an array to hold the data
digitalWrite (csPin, HIGH);

for daisy chained, shift registers, say you had 2: latch low send data send data latch high

digitalWrite (latchPin, LOW);
SPI.transfer(byte0);
SPI.transfer(byte1);
digitalWrite (latchPin, HIGH); // data outputs change on this rising edge

D13/SCK connects to '595 SRCLK D11/MOSI connects to 1st device SER IN D10/SS (latchPin) connects to RCLK '595 OE connects to Gnd, or a PWM output for brightness control '595 SRCLR connects to +5

Thanks for input but as I said I'm just begging with Arduino and selected this project. Just understood about shift registers and lost in the abouve quoted text. Will look into it. Thank you :)

Ok, read about shift registers, look at the slow softwaare bit bang code shiftOut( dataPin, clockPin, MSBFIRST, yourDataToShiftOut ); which says: pick off a data bit from the byte going out, bring the clock line high, bring it low, repeat 7 times

then look at the SPI library SPI.transfer( yourDataToShiftOut ); which says: write a byte to the SPI shift out register and let it independently fly at default 4 MHz clock rate, while the code continues with other stuff. When the SPI hardware sends an interrupt indicating the transfer is done, send the next byte.

CrossRoads:
Ok, read about shift registers, look at the slow softwaare bit bang code
shiftOut( dataPin, clockPin, MSBFIRST, yourDataToShiftOut );
which says: pick off a data bit from the byte going out, bring the clock line high, bring it low, repeat 7 times

then look at the SPI library
SPI.transfer( yourDataToShiftOut );
which says: write a byte to the SPI shift out register and let it independently fly at default 4 MHz clock rate, while the code continues with other stuff. When the SPI hardware sends an interrupt indicating the transfer is done, send the next byte.

Yep just read through shift registers. Seems straight forward. Thank you :slight_smile: looking into MAX7219 now

This looked pretty cool aswell… Should I make use of multiple MAX7219 to mux the LEDs or is there any alternatives??

Yes, 3. One for outer minutes, one for seconds, one to drive 4 digits (28 segments, DP for : or AM/PM indicator), and then up to 32 additional LEDs - hours, days, etc.

CrossRoads: Yes, 3. One for outer minutes, one for seconds, one to drive 4 digits (28 segments, DP for : or AM/PM indicator), and then up to 32 additional LEDs - hours, days, etc.

Thanks a lot.. Could you please teach me how to connect max7219 and to program it in ardueno... Just a link to a guide will also suffice...

http://www.maximintegrated.com/en/products/power/display-power-control/MAX7219.html
Connect SCK to CLK, MOSI to DIN, ssPin to CS.
Connect 15K resistor and 0.1uF, 10uF cap per the datasheet.
I prefer separate CS per device so don’t have to send out a bunch of NOOP commands.
Send register commands and data commands like I showed above.

for (x=0; x<8; x=x+1){
digitalWrite (ssPIN1, LOW); // 1st device
SPI.transfer (x+1); // data register, numbered 1 to 8
SPI.transfer (secondsArray[x]); 
// seconds on/off info held in 8 byte array, secondsArray[0] to [7]
// each byte holds 8 bits, each bit represents a seconds LED. 4 bits in final byte not connected.
digitalWrite (ssPIN1, HIGH); // 1st device

Do similar for minutes, and digits/hours

SPI.transfer(x+1);

CrossRoads:
http://www.maximintegrated.com/en/products/power/display-power-control/MAX7219.html
Connect SCK to CLK, MOSI to DIN, ssPin to CS.
Connect 15K resistor and 0.1uF, 10uF cap per the datasheet.
I prefer separate CS per device so don’t have to send out a bunch of NOOP commands.
Send register commands and data commands like I showed above.

for (x=0; x<8; x=x+1){

digitalWrite (ssPIN1, LOW); // 1st device
SPI.transfer (x+1); // data register, numbered 1 to 8
SPI.transfer (secondsArray);
// seconds on/off info held in 8 byte array, secondsArray[0] to [7]
// each byte holds 8 bits, each bit represents a seconds LED. 4 bits in final byte not connected.
digitalWrite (ssPIN1, HIGH); // 1st device



Do similar for minutes, and digits/hours

SPI.transfer(x+1);

Thanks a ton… Helped loads

Is it possible for me to use 10x 74HC595 shift register instead of MAX7219? If yes, is it efficient??

Here’s how’d you connect 128 LEDs to two MAX7219.
Each one has it’s own chip select, so write to a register in one or the other to change the selected LEDs.
I would use an array of 8 bytes for each, with each byte representing 8 LEDs (same as I would for shift registers).
Then once a second send the 8 bytes out to each part, and whatever had changed for that second would be updated.