No, the shifting out probable needs some adjusting.
Shiftout sends out one byte of data one bit at a time. If you are sending 3 bytes,
10110110 11011011 01000000 data array 12 for example you will need three shiftout commands
Modifying the shiftout example from 2 bytes to 3 would yield something like this:
// Do this for MSBFIRST serial
// replace 'data' with you array definition
// shift out highbyte
shiftOut(dataPin, clock, MSBFIRST, (data >> 8));
// shift out middlebyte
shiftOut(data, clock, MSBFIRST, (data>>8));
// shift out lowbyte
shiftOut(data, clock, MSBFIRST, data8);
This part is reading some buttons? You will need some debounce to keep from getting multiple presses:
hourState = digitalRead(hourPin);
minState = digitalRead(minPin);
//Hour adjustment
if (hourState == HIGH) {
time_t t = now();
t = t + 3600;
setTime(t);
}
//Minute adjustment
if (minState == HIGH) {
time_t t = now();
t = t + 60;
setTime(t);
}
Why not simply the code for writing out the display? You are only updating once a minute and once an hour, right?
So keep track of when the minute changes or when the hour changes and then send out an update.
It looks like
if (hourFormat12() == 11)
&
if (minute() == 0)
do the time tracking for you.
Just sit in a loop, and when you detect a difference, then do the shiftout commands
ex. old_hours = 0;
old_minutes = 0;
new_hours = hourformat12();
new_minutes = minute();
if (new_hours != old_hours) {
// send out new hours
hours = dataArray[new_hours]
digitalWrite(latchPin1, LOW);
shiftOut(dataPin1, clockPin1, MSBFIRST, hours);
digitalWrite(latchPin1, HIGH);
old_hours = new_hours;
}
if (new_minutes != old_minutes){
// do your math here to break up into tens_minutes & ones_minutes
//example
// high_digit = 0
// if (new_minutes <10) {high_digit = 0; low_digit = new_minutes;} // minutes is from 00 to 09
// while (new_minutes >=10 { // loop thru as needed and lop off 10 minutes at a time,
// high_digit = high_digit+1; // updating the high_digit for every 10 minutes
// new_minutes = new_minutes -10;}
// low_digit = new_minutes; // when less than 10 is left, the balance is the low digit
// }
//
tens_minutes = dataArray[high_digit];
ones_minutes = dataArray[low_digit];
digitalWrite(latchPin2, LOW);
digitalWrite(latchPin3, LOW);
shiftOut(dataPin2, clockPin2, MSBFIRST, tens_minutes);
shiftOut(dataPin3, clockPin3, MSBFIRST, one_minutes);
digitalWrite(latchPin2, HIGH);
digitalWrite(latchPin3, HIGH);
old_minutes = new_minutes;
}