I don’t use shiftOut()… see my code below
#include <Wire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <LedControl.h>
// lines to drive the two MAX7219 LED controllers
const int LC1CLK = 11;
const int LC1LOAD = 10;
const int LC1DATA = 12;
LedControl LC1=LedControl(LC1DATA, LC1CLK, LC1LOAD, 2);
tmElements_t tm;
void setup() {
Serial.begin(9600);
while (!Serial) ; // wait for serial
delay(200);
Serial.println("DS1307RTC V1.1 Read Test");
Serial.println("------------------------");
setSyncProvider(RTC.get); // the function to get the time from the RTC
if(timeStatus()!= timeSet) {
Serial.println("Unable to sync with the RTC");
Serial.println("Time set to the default: 00:00:00");
tm.Hour = 0;
tm.Minute= 0;
tm.Second = 0;
RTC.write(tm); //set the time to 00:00:00
}
// the zero refers to the MAX7219 number, it is zero for 1 chip
LC1.shutdown(0,false);// turn off power saving, enables display
LC1.setIntensity(0,15);// sets brightness (0~15 possible values)
LC1.clearDisplay(0);// clear screen
LC1.shutdown(1,false);// turn off power saving, enables display
LC1.setIntensity(1,15);// sets brightness (0~15 possible values: 0 = dim, 15 = full brightness)
LC1.clearDisplay(1);// clear screen
}
void loop() {
if (RTC.read(tm)) {
Serial.print("Ok, Time = ");
print2digits(tm.Hour);
Serial.write(':');
print2digits(tm.Minute);
Serial.write(':');
print2digits(tm.Second);
Serial.println();
} else {
if (RTC.chipPresent()) {
Serial.println("The DS1307 is stopped. Please run the SetTime to initialize the time and begin running."); //"The DS1307 is stopped. Please run the SetTime"
//Serial.println("example to initialize the time and begin running.");
Serial.println();
} else {
Serial.println("DS1307 read error! Please check the circuitry.");
Serial.println();
Fault();
}
delay(9000);
}
if (tm.Minute % 5 == 0 ) {
FillMatrix();
}
}
void FillMatrix(){
//Clear the whole matrix
Clear_Matrix();
switch (tm.Hour) {
case 1:
String1();
break;
case 2:
String2();
break;
case 3:
String3();
break;
case 4:
String4();
break;
case 5:
String5();
break;
case 6:
String6();
break;
case 7:
String7();
break;
case 8:
String8();
break;
case 9:
String9();
break;
case 10:
String10();
break;
case 11:
String11();
break;
case 12:
String12();
break;
}
Empty();
}
void print2digits(int number) {
if (number >= 0 && number < 10) {
Serial.write('0');
}
Serial.print(number);
}
//Clear the matrix
void Clear_Matrix() {
LC1.clearDisplay(0);
LC1.clearDisplay(1);
}
void String1() {
LC1.setLed(1,2,0, true);
LC1.setLed(1,2,1, true);
LC1.setLed(1,2,2, true);
LC1.setLed(0,0,5, true);
LC1.setLed(0,0,6, true);
}
void String2() {
LC1.setLed(2,2,0, true);
LC1.setLed(2,2,1, true);
LC1.setLed(2,2,2, true);
LC1.setLed(0,1,5, true);
LC1.setLed(0,1,6, true);
}