Matrix clock

I am trying to build a matrix clock to display a scrolling time and date but have run into a conversion problem. I am using 5 max7219 8x8 displays and a ds1307 rtc, and have combined a matrix sketch and a ds1307 sketch, both on their own are working, it’s how to convert the ds1307 output into the matrix is where I am having the problem, I know that letters and numbers have to be put into char strings that is not a problem, it is getting the ds1307 time and date to be displayed. Any help will be welcomed.
Enclosed is what I have done so far.

[/// Binary letters and numbers
//B01100000, B00011000, B00000110, B00000001, B00000000, // /
//B00111110, B01000001, B01000001, B00111110, B00000000, // 0
//B01000010, B01111111, B01000000, B00000000, B00000000, // 1
//B01100010, B01010001, B01001001, B01000110, B00000000, // 2
//B00100010, B01000001, B01001001, B00110110, B00000000, // 3
//B00011000, B00010100, B00010010, B01111111, B00000000, // 4
//B00100111, B01000101, B01000101, B00111001, B00000000, // 5
//B00111110, B01001001, B01001001, B00110000, B00000000, // 6
//B01100001, B00010001, B00001001, B00000111, B00000000, // 7
//B00110110, B01001001, B01001001, B00110110, B00000000, // 8
//B00000110, B01001001, B01001001, B00111110, B00000000, // 9
//B01010000, B00000000, B00000000, B00000000, B00000000, // :
//B01111110, B00010001, B00010001, B01111110, B00000000, // A
//B01111111, B01001001, B01001001, B00110110, B00000000, // B
//B00111110, B01000001, B01000001, B00100010, B00000000, // C
//B01111111, B01000001, B01000001, B00111110, B00000000, // D
//B01111111, B01001001, B01001001, B01000001, B00000000, // E
//B01111111, B00001001, B00001001, B00000001, B00000000, // F
//B00111110, B01000001, B01001001, B01111010, B00000000, // G
//B01111111, B00001000, B00001000, B01111111, B00000000, // H
//B01000001, B01111111, B01000001, B00000000, B00000000, // I
//B00110000, B01000000, B01000001, B00111111, B00000000, // J
//B01111111, B00001000, B00010100, B01100011, B00000000, // K
//B01111111, B01000000, B01000000, B01000000, B00000000, // L
//B01111111, B00000010, B00001100, B00000010, B01111111, // M
//B01111111, B00000100, B00001000, B00010000, B01111111, // N
//B00111110, B01000001, B01000001, B00111110, B00000000, // O
//B01111111, B00001001, B00001001, B00000110, B00000000, // P
//B00111110, B01000001, B01000001, B10111110, B00000000, // Q
//B01111111, B00001001, B00001001, B01110110, B00000000, // R
//B01000110, B01001001, B01001001, B00110010, B00000000, // S
//B00000001, B00000001, B01111111, B00000001, B00000001, // T
//B00111111, B01000000, B01000000, B00111111, B00000000, // U
//B00001111, B00110000, B01000000, B00110000, B00001111, // V
//B00111111, B01000000, B00111000, B01000000, B00111111, // W
//B01100011, B00010100, B00001000, B00010100, B01100011, // X
//B00000111, B00001000, B01110000, B00001000, B00000111, // Y
//B01100001, B01010001, B01001001, B01000111, B00000000, // Z

#include <SPI.h>
#include <Wire.h>
#include "RTClib.h"
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>

int pinCS = 10; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI )
int numberOfHorizontalDisplays = 5;
int numberOfVerticalDisplays = 1;

Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
RTC_DS1307 rtc;

// Need to insert Time and Date inbetween, then after delay Time is shown for a set period then repeated
String tape = "The Time is:  The Date is:  ";   
int wait = 50; // In milliseconds

int spacer = 1;
int width = 5 + spacer; // The font width is 5 pixels

void setup() {
  
  matrix.setIntensity(0); // Use a value between 0 and 15 for brightness
  #ifdef AVR
  Wire.begin();
#else
  Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
  rtc.begin();
  
 if (! rtc.isrunning()) {
    matrix.print("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(__DATE__, __TIME__));
  }
} 

// Adjust to your own needs
//  matrix.setPosition(0, 0, 0); // The first display is at <0, 0>
//  matrix.setPosition(1, 1, 0); // The second display is at <1, 0>
//  matrix.setPosition(2, 2, 0); // The third display is at <2, 0>
//  matrix.setPosition(3, 3, 0); // And the last display is at <3, 0>
//  ...
//  matrix.setRotation(0, 2);    // The first display is position upside down
//  matrix.setRotation(3, 2);    // The same hold for the last display


void loop() {

  for ( int i = 0 ; i < width * tape.length() + matrix.width() - 1 - spacer; i++ ) {

    matrix.fillScreen(LOW);

    int letter = i / width;
    int x = (matrix.width() - 1) - i % width;
    int y = (matrix.height() - 8) / 2; // center the text vertically

    while ( x + width - spacer >= 0 && letter >= 0 ) {
      if ( letter < tape.length() ) {
        matrix.drawChar(x, y, tape[letter], HIGH, LOW, 1);
      }

      letter--;
      x -= width;
    }

    matrix.write(); // Send bitmap to display

{
    DateTime now = rtc.now();
    
    matrix.setPosition(0,0,0);
    matrix.print(now.hour(), DEC);
    matrix.print(':');
    matrix.print(now.minute(), DEC);
    matrix.print(':');
    matrix.print(now.second(), DEC);
    
    
    matrix.setPosition(0,0,0);
    matrix.print(now.day(), DEC);
    matrix.print('/');
    matrix.print(now.month(), DEC);
    matrix.print('/');
    matrix.print(now.year(), DEC);
    matrix.print(' ');
    
        
    delay(wait);
}



    delay(100);
  }
}
code]

JQuinn:
it’s how to convert the ds1307 output into the matrix is where I am having the problem, I know that letters and numbers have to be put into char strings that is not a problem, it is getting the ds1307 time and date to be displayed.

I looked at your code, and I really don’t see any numbers from the date or time being put into character strings.

By the way, you probably want to use a string (lowercase s) rather than a String (capital S). And the function for getting the length of a string is strlen(). Yes, the official Arduino documentation is very incomplete.

Below is my attempt at modifying your code. I have not run it myself (nor have I the hardware to run it myself), so it might contain bugs. Try it out and see what happens.

/// Binary letters and numbers
//B01100000, B00011000, B00000110, B00000001, B00000000, // /
//B00111110, B01000001, B01000001, B00111110, B00000000, // 0
//B01000010, B01111111, B01000000, B00000000, B00000000, // 1
//B01100010, B01010001, B01001001, B01000110, B00000000, // 2
//B00100010, B01000001, B01001001, B00110110, B00000000, // 3
//B00011000, B00010100, B00010010, B01111111, B00000000, // 4
//B00100111, B01000101, B01000101, B00111001, B00000000, // 5
//B00111110, B01001001, B01001001, B00110000, B00000000, // 6
//B01100001, B00010001, B00001001, B00000111, B00000000, // 7
//B00110110, B01001001, B01001001, B00110110, B00000000, // 8
//B00000110, B01001001, B01001001, B00111110, B00000000, // 9
//B01010000, B00000000, B00000000, B00000000, B00000000, // :
//B01111110, B00010001, B00010001, B01111110, B00000000, // A
//B01111111, B01001001, B01001001, B00110110, B00000000, // B
//B00111110, B01000001, B01000001, B00100010, B00000000, // C
//B01111111, B01000001, B01000001, B00111110, B00000000, // D
//B01111111, B01001001, B01001001, B01000001, B00000000, // E
//B01111111, B00001001, B00001001, B00000001, B00000000, // F
//B00111110, B01000001, B01001001, B01111010, B00000000, // G
//B01111111, B00001000, B00001000, B01111111, B00000000, // H
//B01000001, B01111111, B01000001, B00000000, B00000000, // I
//B00110000, B01000000, B01000001, B00111111, B00000000, // J
//B01111111, B00001000, B00010100, B01100011, B00000000, // K
//B01111111, B01000000, B01000000, B01000000, B00000000, // L
//B01111111, B00000010, B00001100, B00000010, B01111111, // M
//B01111111, B00000100, B00001000, B00010000, B01111111, // N
//B00111110, B01000001, B01000001, B00111110, B00000000, // O
//B01111111, B00001001, B00001001, B00000110, B00000000, // P
//B00111110, B01000001, B01000001, B10111110, B00000000, // Q
//B01111111, B00001001, B00001001, B01110110, B00000000, // R
//B01000110, B01001001, B01001001, B00110010, B00000000, // S
//B00000001, B00000001, B01111111, B00000001, B00000001, // T
//B00111111, B01000000, B01000000, B00111111, B00000000, // U
//B00001111, B00110000, B01000000, B00110000, B00001111, // V
//B00111111, B01000000, B00111000, B01000000, B00111111, // W
//B01100011, B00010100, B00001000, B00010100, B01100011, // X
//B00000111, B00001000, B01110000, B00001000, B00000111, // Y
//B01100001, B01010001, B01001001, B01000111, B00000000, // Z

#include <SPI.h>
#include <Wire.h>
#include "RTClib.h"
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>

int pinCS = 10; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI )
int numberOfHorizontalDisplays = 5;
int numberOfVerticalDisplays = 1;

Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
RTC_DS1307 rtc;

// Need to insert Time and Date inbetween, then after delay Time is shown for a set period then repeated
string tape = "The date is 99/99/9999      The time is 99:99:99";
// count ones  0123456789012345678901234567890123456789012345678
//       tens  0         1         2         3         4
// so our string is forty-eight characters long
int tape_length = 48;

int wait = 50; // In milliseconds

int spacer = 1;
int width = 5 + spacer; // The font width is 5 pixels

void setup() {
  
  matrix.setIntensity(0); // Use a value between 0 and 15 for brightness
  #ifdef AVR
  Wire.begin();
#else
  Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
  rtc.begin();
  
 if (! rtc.isrunning()) {
    matrix.print("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(__DATE__, __TIME__));
  }
} 

// Adjust to your own needs
//  matrix.setPosition(0, 0, 0); // The first display is at <0, 0>
//  matrix.setPosition(1, 1, 0); // The second display is at <1, 0>
//  matrix.setPosition(2, 2, 0); // The third display is at <2, 0>
//  matrix.setPosition(3, 3, 0); // And the last display is at <3, 0>
//  ...
//  matrix.setRotation(0, 2);    // The first display is position upside down
//  matrix.setRotation(3, 2);    // The same hold for the last display


void loop() {

  DateTime now = rtc.now();
  // modify our tape to show the date and time
  tape[12] = '0' + ((now.day())/10); // I assume you want the day first
  tape[13] = '0' + ((now.day())%10);
  tape[15] = '0' + ((now.month())/10);
  tape[16] = '0' + ((now.month())%10);
  tape[18] = '0' + ((now.year())/1000);
  tape[19] = '0' + (((now.year())/100)%10);
  tape[20] = '0' + (((now.year())/10)%10);
  tape[21] = '0' + ((now.year())%10);
  tape[40] = '0' + ((now.hour())/10);
  tape[41] = '0' + ((now.hour())%10);
  tape[43] = '0' + ((now.minute())/10);
  tape[44] = '0' + ((now.minute())%10);
  tape[46] = '0' + ((now.second())/10);
  tape[47] = '0' + ((now.second())%10);

  for ( int i = 0 ; i < width * tape_length + matrix.width() - 1 - spacer; i++ ) {

    matrix.fillScreen(LOW);

    int letter = i / width;
    int x = (matrix.width() - 1) - i % width;
    int y = (matrix.height() - 8) / 2; // center the text vertically

    while ( x + width - spacer >= 0 && letter >= 0 ) {
      if ( letter < tape_length ) {
        matrix.drawChar(x, y, tape[letter], HIGH, LOW, 1);
      }

      letter--;
      x -= width;
    }

    matrix.write(); // Send bitmap to display
        
    delay(wait);

  }
}

The changes to the code work like a charm, except ‘string tape’ has to be ‘String tape’ put it down to big fingers, now the basic code is working, time to refine and modify the program.
Many THANKS for your help, one headache out of the road.