i need your good advise. I am using 4x 7 seg custom built led display and with the help of sn74hc595 i would love to display clock information using a RTC module DS3231.
what is the best way to write to the shift registers ? how to update clock information ?
The link of yours helped me. I have adapted the code and i was able to display the clock.
The simple thing which i did not understood was that the when you create the rtc.now() object you have already the nice classes of hours, minutes, seconds... which you can access just as is without worrying that you need to calculate now the hours or minutes...
DateTime clock = rtc.now();
int hours = clock.hour();
int minutes = clock.minute();
int seconds = clock.second();
int hleft = hours/10;
int hright = hours%10;
int mleft = minutes/10;
int mright = minutes%10;
int sleft = seconds/10;
int sright = seconds%10;
//Hours Left
switch (hleft){
case 0:
hleft = 63;
break;
case 1:
hleft = 06;
break;
case 2:
hleft = 91;
break;
}
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, MSBFIRST, hleft); // Hour left digit
shiftOut(datapin, clockpin, MSBFIRST, hright); // Hour right digit
shiftOut(datapin, clockpin, MSBFIRST, mleft); // Minute left digit
shiftOut(datapin, clockpin, MSBFIRST, mright); // Minute right digit
digitalWrite(latchpin, HIGH);
With simple division and modulo calculation the result was as desired. Thanks again. I am moving on creating some menus now, where all the interaction needs to be done from a clicker.
First, connect the Serial Input Pin of 74HC595 Shift Register to Pin 4 of Arduino. Then connect the clock and latch pins i.e. pins 11 and 12 of 74HC595 to pins 6 and 5 of Arduino respectively. Now, connect 8 LEDs with individual current limiting 1KΩ Resistors to the 8 output pins of 74HC595 IC. official website