No seconds on Matrix clock

I have build a matrix clock to display a scrolling time and date and modified the program to display time only for a set period then back to repeating scrolling and display time.
The problem I have is that when the time only is displayed the seconds do not advance to change minutes, and minutes do not change hours when required.
I am using 6 max7219 8x8 displays, a ds1307 rtc, and a mega 2560,libraries used are SPI, Wire, RTClib, Adafruit_GFX, Max72xxPanel.
I have searched the forum for ideas but most refer to either 7seg readouts or only show hh:mm no seconds.
This is an ongoing project where temp/humi, and buttons to display other things will be added.
Any advice will be welcomed, and a thank you in advance for any help.
Program is listed below, it runs on both uno and mega2560, by changing pins.

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

/* Max7219 settings */
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;

unsigned char a;
 unsigned char j;
 
/*Port Definitions UNO*/
int Max7219_pinCLK = 13; //Mega SCK-52
int Max7219_pinCS = 10; //Mega CS-10
int Max7219_pinDIN = 11; //Mega DIN-MOSI
 
unsigned char disp1[38][8]={
{0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C},//0
{0x10,0x18,0x14,0x10,0x10,0x10,0x10,0x10},//1
{0x7E,0x2,0x2,0x7E,0x40,0x40,0x40,0x7E},//2
{0x3E,0x2,0x2,0x3E,0x2,0x2,0x3E,0x0},//3
{0x8,0x18,0x28,0x48,0xFE,0x8,0x8,0x8},//4
{0x3C,0x20,0x20,0x3C,0x4,0x4,0x3C,0x0},//5
{0x3C,0x20,0x20,0x3C,0x24,0x24,0x3C,0x0},//6
{0x3E,0x22,0x4,0x8,0x8,0x8,0x8,0x8},//7
{0x0,0x3E,0x22,0x22,0x3E,0x22,0x22,0x3E},//8
{0x3E,0x22,0x22,0x3E,0x2,0x2,0x2,0x3E},//9
{0x8,0x14,0x22,0x3E,0x22,0x22,0x22,0x22},//A
{0x3C,0x22,0x22,0x3E,0x22,0x22,0x3C,0x0},//B
{0x3C,0x40,0x40,0x40,0x40,0x40,0x3C,0x0},//C
{0x7C,0x42,0x42,0x42,0x42,0x42,0x7C,0x0},//D
{0x7C,0x40,0x40,0x7C,0x40,0x40,0x40,0x7C},//E
{0x7C,0x40,0x40,0x7C,0x40,0x40,0x40,0x40},//F
{0x3C,0x40,0x40,0x40,0x40,0x44,0x44,0x3C},//G
{0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x44},//H
{0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x7C},//I
{0x3C,0x8,0x8,0x8,0x8,0x8,0x48,0x30},//J
{0x0,0x24,0x28,0x30,0x20,0x30,0x28,0x24},//K
{0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7C},//L
{0x81,0xC3,0xA5,0x99,0x81,0x81,0x81,0x81},//M
{0x0,0x42,0x62,0x52,0x4A,0x46,0x42,0x0},//N
{0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C},//O
{0x3C,0x22,0x22,0x22,0x3C,0x20,0x20,0x20},//P
{0x1C,0x22,0x22,0x22,0x22,0x26,0x22,0x1D},//Q
{0x3C,0x22,0x22,0x22,0x3C,0x24,0x22,0x21},//R
{0x0,0x1E,0x20,0x20,0x3E,0x2,0x2,0x3C},//S
{0x0,0x3E,0x8,0x8,0x8,0x8,0x8,0x8},//T
{0x42,0x42,0x42,0x42,0x42,0x42,0x22,0x1C},//U
{0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18},//V
{0x0,0x49,0x49,0x49,0x49,0x2A,0x1C,0x0},//W
{0x0,0x41,0x22,0x14,0x8,0x14,0x22,0x41},//X
{0x41,0x22,0x14,0x8,0x8,0x8,0x8,0x8},//Y
{0x0,0x7F,0x2,0x4,0x8,0x10,0x20,0x7F},//Z
};

/* Set up Scrolling Time and Date settings */
String tape ="99:99:99  99/99/9999";
int tape_length = 22;
int wait = 50; // In milliseconds

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

/* Set up display of Time only */
void Write_Max7219_byte(unsigned char DATA) 
{   
            unsigned char a;
	    digitalWrite(Max7219_pinCS,LOW);		
	    for(a=8;a>=1;a--)
          {		  
             digitalWrite(Max7219_pinCLK,LOW);
             digitalWrite(Max7219_pinDIN,DATA&0x80);// Extracting a bit data
             DATA = DATA<<1;
             digitalWrite(Max7219_pinCLK,HIGH);
           }                                 
}
 
 
void Write_Max7219(unsigned char address,unsigned char dat)
{
        digitalWrite(Max7219_pinCS,LOW);
        Write_Max7219_byte(address);           //address,code of LED
        Write_Max7219_byte(dat);               //data,figure on LED 
        digitalWrite(Max7219_pinCS,HIGH);
}
 
void Init_MAX7219(void)
{
 Write_Max7219(0x09, 0x00);       //decoding :BCD
 Write_Max7219(0x0a, 0x03);       //brightness 
 Write_Max7219(0x0b, 0x07);       //scanlimit;8 LEDs
 Write_Max7219(0x0c, 0x01);       //power-down mode:0,normal mode:1
 Write_Max7219(0x0f, 0x00); //test display:1;EOT,display:0
 
}

void setup()
{
  
/*Init Max7219*/  
  pinMode(Max7219_pinCLK,OUTPUT);
  pinMode(Max7219_pinCS,OUTPUT);
  pinMode(Max7219_pinDIN,OUTPUT);
  delay(50);
  Init_MAX7219();
  
/* Check if RTC running and set intensity of display */  
 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__));
  }
}

void loop() {

  DateTime now = rtc.now();
  
  
  /* Scrolling to show the date and time */
  
  tape[0] = '0' + ((now.hour())/10);  // I assume you want the time first
  tape[1] = '0' + ((now.hour())%10);
  tape[3] = '0' + ((now.minute())/10);
  tape[4] = '0' + ((now.minute())%10);
  tape[6] = '0' + ((now.second())/10);
  tape[7] = '0' + ((now.second())%10);
  
  tape[10] = '0' + ((now.day())/10); 
  tape[11] = '0' + ((now.day())%10);
  tape[13] = '0' + ((now.month())/10);
  tape[14] = '0' + ((now.month())%10);
  tape[16] = '0' + ((now.year())/1000);
  tape[17] = '0' + (((now.year())/100)%10);
  tape[18] = '0' + (((now.year())/10)%10);
  tape[19] = '0' + ((now.year())%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);    
}
/* Print time only */
char timeStr[4]; // enough space for "XX:XX\0"
sprintf( timeStr, "%02d:%02d", now.hour(), now.minute(), now.second());
matrix.print( timeStr );
matrix.write();

for(j=0;j<38;j++)
  {
   for(a=1;a<9;a++)
    Write_Max7219(a,disp1[j][a-1]);
   delay(700);

}
}code]

I'm guessing you problem is here:

/* Print time only */
char timeStr[4]; // enough space for "XX:XX\0"
sprintf( timeStr, "%02d:%02d", now.hour(), now.minute(), now.second());
matrix.print( timeStr );
matrix.write();

A four character array is not long enough to the hold six characters you say it will, let alone the nine you actually want.

When you only specify two formats, sprintf() will not use the third value you provide.

Try this instead:

/* Print time only */
char timeStr[9]; // enough space for "XX:XX:XX\0"
sprintf( timeStr, "%02d:%02d:%02d", now.hour(), now.minute(), now.second());
matrix.print( timeStr );
matrix.write();

OOP's the (timeStr) was supposed to be 6, my mistake, didn't check program before posting, 9 won't allow the time display to be shown at all. Seems to be a problem between the scrolling part and the time, when program is rewritten without the scrolling, time works with seconds working but it then has a flickering problem, so its back to square one.

Corrected code below

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

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


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

unsigned char a;
 unsigned char j;
 
/*Port Definitions UNO*/
int Max7219_pinCLK = 13; //Mega SCK-52
int Max7219_pinCS = 10; //Mega CS-10
int Max7219_pinDIN = 11; //Mega DIN-MOSI
 
unsigned char disp1[38][8]={
{0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C},//0
{0x10,0x18,0x14,0x10,0x10,0x10,0x10,0x10},//1
{0x7E,0x2,0x2,0x7E,0x40,0x40,0x40,0x7E},//2
{0x3E,0x2,0x2,0x3E,0x2,0x2,0x3E,0x0},//3
{0x8,0x18,0x28,0x48,0xFE,0x8,0x8,0x8},//4
{0x3C,0x20,0x20,0x3C,0x4,0x4,0x3C,0x0},//5
{0x3C,0x20,0x20,0x3C,0x24,0x24,0x3C,0x0},//6
{0x3E,0x22,0x4,0x8,0x8,0x8,0x8,0x8},//7
{0x0,0x3E,0x22,0x22,0x3E,0x22,0x22,0x3E},//8
{0x3E,0x22,0x22,0x3E,0x2,0x2,0x2,0x3E},//9
{0x8,0x14,0x22,0x3E,0x22,0x22,0x22,0x22},//A
{0x3C,0x22,0x22,0x3E,0x22,0x22,0x3C,0x0},//B
{0x3C,0x40,0x40,0x40,0x40,0x40,0x3C,0x0},//C
{0x7C,0x42,0x42,0x42,0x42,0x42,0x7C,0x0},//D
{0x7C,0x40,0x40,0x7C,0x40,0x40,0x40,0x7C},//E
{0x7C,0x40,0x40,0x7C,0x40,0x40,0x40,0x40},//F
{0x3C,0x40,0x40,0x40,0x40,0x44,0x44,0x3C},//G
{0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x44},//H
{0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x7C},//I
{0x3C,0x8,0x8,0x8,0x8,0x8,0x48,0x30},//J
{0x0,0x24,0x28,0x30,0x20,0x30,0x28,0x24},//K
{0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7C},//L
{0x81,0xC3,0xA5,0x99,0x81,0x81,0x81,0x81},//M
{0x0,0x42,0x62,0x52,0x4A,0x46,0x42,0x0},//N
{0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C},//O
{0x3C,0x22,0x22,0x22,0x3C,0x20,0x20,0x20},//P
{0x1C,0x22,0x22,0x22,0x22,0x26,0x22,0x1D},//Q
{0x3C,0x22,0x22,0x22,0x3C,0x24,0x22,0x21},//R
{0x0,0x1E,0x20,0x20,0x3E,0x2,0x2,0x3C},//S
{0x0,0x3E,0x8,0x8,0x8,0x8,0x8,0x8},//T
{0x42,0x42,0x42,0x42,0x42,0x42,0x22,0x1C},//U
{0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18},//V
{0x0,0x49,0x49,0x49,0x49,0x2A,0x1C,0x0},//W
{0x0,0x41,0x22,0x14,0x8,0x14,0x22,0x41},//X
{0x41,0x22,0x14,0x8,0x8,0x8,0x8,0x8},//Y
{0x0,0x7F,0x2,0x4,0x8,0x10,0x20,0x7F},//Z
};

/* Set up Scrolling Time and Date settings */
String tape ="99:99:99  99/99/9999";
int tape_length = 22;
int wait = 50; // In milliseconds

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

/* Set up display of Time only */
void Write_Max7219_byte(unsigned char DATA) 
{   
            unsigned char a;
	    digitalWrite(Max7219_pinCS,LOW);		
	    for(a=8;a>=1;a--)
          {		  
             digitalWrite(Max7219_pinCLK,LOW);
             digitalWrite(Max7219_pinDIN,DATA&0x80);// Extracting a bit data
             DATA = DATA<<1;
             digitalWrite(Max7219_pinCLK,HIGH);
           }                                 
}
 
 
void Write_Max7219(unsigned char address,unsigned char dat)
{
        digitalWrite(Max7219_pinCS,LOW);
        Write_Max7219_byte(address);           //address,code of LED
        Write_Max7219_byte(dat);               //data,figure on LED 
        digitalWrite(Max7219_pinCS,HIGH);
}
 
void Init_MAX7219(void)
{
 Write_Max7219(0x09, 0x00);       //decoding :BCD
 Write_Max7219(0x0a, 0x03);       //brightness 
 Write_Max7219(0x0b, 0x07);       //scanlimit;8 LEDs
 Write_Max7219(0x0c, 0x01);       //power-down mode:0,normal mode:1
 Write_Max7219(0x0f, 0x00); //test display:1;EOT,display:0
 
}

void setup()
{
  
/*Init Max7219*/  
  pinMode(Max7219_pinCLK,OUTPUT);
  pinMode(Max7219_pinCS,OUTPUT);
  pinMode(Max7219_pinDIN,OUTPUT);
  delay(50);
  Init_MAX7219();
  
/* Check if RTC running and set intensity of display */  
 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__));
  }
}

void loop() {

  DateTime now = rtc.now();
  
  
  /* Scrolling to show the date and time */
  
  tape[0] = '0' + ((now.hour())/10);  // I assume you want the time first
  tape[1] = '0' + ((now.hour())%10);
  tape[3] = '0' + ((now.minute())/10);
  tape[4] = '0' + ((now.minute())%10);
  tape[6] = '0' + ((now.second())/10);
  tape[7] = '0' + ((now.second())%10);
  
  tape[10] = '0' + ((now.day())/10); 
  tape[11] = '0' + ((now.day())%10);
  tape[13] = '0' + ((now.month())/10);
  tape[14] = '0' + ((now.month())%10);
  tape[16] = '0' + ((now.year())/1000);
  tape[17] = '0' + (((now.year())/100)%10);
  tape[18] = '0' + (((now.year())/10)%10);
  tape[19] = '0' + ((now.year())%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);    
}
/* Print time only */
char timeStr[6]; // enough space for "XX:XX:XX\0"
sprintf( timeStr, "%02d:%02d:%02d", now.hour(), now.minute(), now.second());
matrix.print( timeStr );
matrix.write();

for(j=0;j<38;j++)
  {
   for(a=1;a<9;a++)
    Write_Max7219(a,disp1[j][a-1]);
   delay(700);

}
}code]
char timeStr[6]; // enough space for "XX:XX:XX\0"

BZZZZZT!

char timeStr[6]; // enough space for "XX:XX:XX\0"

No, it isn't. You can't store 9 characters in a 6 character array.

[u]AWOL[/u] what advice is 'BZZZZZT' supposed to be.

[u]johnwasser[/u] any more than 6 and no time display as explained before.

If you take the time to run the program you will see what I mean!

It's my "heads-up" buzzer. It means "there's something very wrong with either the code or the comment and you'd better fix it"

That’s why I have come on to the forum for advice from people with more ‘knowledge/experience’ than me as to how,what or why the problem has happened.
I have rewritten the program so as to have only the scrolling, and rewritten the program to have only time with it showing seconds, but put together there is scrolling and time but no seconds, that is the reason I have asked for advice from the forum.

In reply #1 it was pointed out that a four character array was too small for the six characters you were going to store in it, but by reply #3 this still hadn't been corrected, despite your description of it as "fixed".

If you take the time to run the program you will see what I mean!

You're assuming there that we have the hardware to run your sketch.

If you make 'timeStr' 6 or 7, time is shown after the scrolling but no seconds display, if you put in 8 or 9 then there is no time displayed only the delay before it scrolls time and date, how do you explain that! If you run the program as in reply #3 you will see that it runs but no seconds are displayed, which was the point of asking for advice as to why no seconds are displayed.

If you run the program as in reply #3

Again, I don't have your hardware. I don't even have an Arduino, so all I can do is point out to you the glaringly obvious, and wait for you to fix them and retest.

Whether or not you fix those problems and post your corrected code is entirely up to you.

You have told the library your display is 40x8 pixels. Characters are 6x8 (5x7 plus spacing). 40/6=6 2/3 so you can only fit six and two thirds characters in your display. How did you intend to display 8 characters (HH:MM:SS)?!?

You should probably position the cursor before displaying text.

    matrix.setCursor(0,0);
    matrix.print( timeStr );

Here is the code with ‘timeStr’ 8, when compiled and run time and date are scrolled then only time is displayed ‘HH:MM:SS’ with the seconds not counting only a static display, and after the delay, time and date are then scrolled, then there is no display of time, this then repeats, scrolling no time display etc etc for as long as the program is run.
If ‘timeStr’ is either 6 or 7, time is displayed after the scrolling of time and date every time.
My problem still is how to get the time only display to show the seconds counting to change minutes etc.
The only thing that has changed in the program is ‘timeStr’s’ value and the delay to speed up testing.

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

/* Max7219 settings */
int pinCS = 10; // Attach CS to UNO/11/12,Mega/10 , DIN to MOSI UNO/11/12, Mega/51 and CLK to SCK UNO/13/11,Mega/52 (cf http://arduino.cc/en/Reference/SPI )
int numberOfHorizontalDisplays = 6;
int numberOfVerticalDisplays = 1;


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

//DS1307 Pins UNO SDA-A4, CLK-A5, Mega SDA-D21, CLK-D20
RTC_DS1307 rtc;

unsigned char a;
 unsigned char j;
 
/*Port Definitions*/
int Max7219_pinCLK = 13;
int Max7219_pinCS = 10;
int Max7219_pinDIN = 11;
 
unsigned char disp1[38][8]={
{0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C},//0
{0x10,0x18,0x14,0x10,0x10,0x10,0x10,0x10},//1
{0x7E,0x2,0x2,0x7E,0x40,0x40,0x40,0x7E},//2
{0x3E,0x2,0x2,0x3E,0x2,0x2,0x3E,0x0},//3
{0x8,0x18,0x28,0x48,0xFE,0x8,0x8,0x8},//4
{0x3C,0x20,0x20,0x3C,0x4,0x4,0x3C,0x0},//5
{0x3C,0x20,0x20,0x3C,0x24,0x24,0x3C,0x0},//6
{0x3E,0x22,0x4,0x8,0x8,0x8,0x8,0x8},//7
{0x0,0x3E,0x22,0x22,0x3E,0x22,0x22,0x3E},//8
{0x3E,0x22,0x22,0x3E,0x2,0x2,0x2,0x3E},//9
{0x8,0x14,0x22,0x3E,0x22,0x22,0x22,0x22},//A
{0x3C,0x22,0x22,0x3E,0x22,0x22,0x3C,0x0},//B
{0x3C,0x40,0x40,0x40,0x40,0x40,0x3C,0x0},//C
{0x7C,0x42,0x42,0x42,0x42,0x42,0x7C,0x0},//D
{0x7C,0x40,0x40,0x7C,0x40,0x40,0x40,0x7C},//E
{0x7C,0x40,0x40,0x7C,0x40,0x40,0x40,0x40},//F
{0x3C,0x40,0x40,0x40,0x40,0x44,0x44,0x3C},//G
{0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x44},//H
{0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x7C},//I
{0x3C,0x8,0x8,0x8,0x8,0x8,0x48,0x30},//J
{0x0,0x24,0x28,0x30,0x20,0x30,0x28,0x24},//K
{0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7C},//L
{0x81,0xC3,0xA5,0x99,0x81,0x81,0x81,0x81},//M
{0x0,0x42,0x62,0x52,0x4A,0x46,0x42,0x0},//N
{0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C},//O
{0x3C,0x22,0x22,0x22,0x3C,0x20,0x20,0x20},//P
{0x1C,0x22,0x22,0x22,0x22,0x26,0x22,0x1D},//Q
{0x3C,0x22,0x22,0x22,0x3C,0x24,0x22,0x21},//R
{0x0,0x1E,0x20,0x20,0x3E,0x2,0x2,0x3C},//S
{0x0,0x3E,0x8,0x8,0x8,0x8,0x8,0x8},//T
{0x42,0x42,0x42,0x42,0x42,0x42,0x22,0x1C},//U
{0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18},//V
{0x0,0x49,0x49,0x49,0x49,0x2A,0x1C,0x0},//W
{0x0,0x41,0x22,0x14,0x8,0x14,0x22,0x41},//X
{0x41,0x22,0x14,0x8,0x8,0x8,0x8,0x8},//Y
{0x0,0x7F,0x2,0x4,0x8,0x10,0x20,0x7F},//Z
};

/* Set up Scrolling Time and Date settings */
String tape ="99:99:99  99/99/9999";
int tape_length = 22;
int wait = 50; // In milliseconds

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

/* Set up display of Time only */
void Write_Max7219_byte(unsigned char DATA) 
{   
            unsigned char a;
    digitalWrite(Max7219_pinCS,LOW); 
    for(a=8;a>=1;a--)
          {  
             digitalWrite(Max7219_pinCLK,LOW);
             digitalWrite(Max7219_pinDIN,DATA&0x80);// Extracting a bit data
             DATA = DATA<<1;
             digitalWrite(Max7219_pinCLK,HIGH);
           }                                 
}
 
 
void Write_Max7219(unsigned char address,unsigned char dat)
{
        digitalWrite(Max7219_pinCS,LOW);
        Write_Max7219_byte(address);           //address,code of LED
        Write_Max7219_byte(dat);               //data,figure on LED 
        digitalWrite(Max7219_pinCS,HIGH);
}
 
void Init_MAX7219(void)
{
 Write_Max7219(0x09, 0x00);       //decoding :BCD
 Write_Max7219(0x0a, 0x03);       //brightness 
 Write_Max7219(0x0b, 0x07);       //scanlimit;8 LEDs
 Write_Max7219(0x0c, 0x01);       //power-down mode:0,normal mode:1
 Write_Max7219(0x0f, 0x00); //test display:1;EOT,display:0
 
}

void setup()
{
  
/*Init Max7219*/  
  pinMode(Max7219_pinCLK,OUTPUT);
  pinMode(Max7219_pinCS,OUTPUT);
  pinMode(Max7219_pinDIN,OUTPUT);
  delay(50);
  Init_MAX7219();
  
/* Check if RTC running and set intensity of display */  
 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__));
  }
}

void loop() {

  DateTime now = rtc.now();
  
  
  /* Scrolling to show the date and time */
  
  tape[0] = '0' + ((now.hour())/10);  // I assume you want the time first
  tape[1] = '0' + ((now.hour())%10);
  tape[3] = '0' + ((now.minute())/10);
  tape[4] = '0' + ((now.minute())%10);
  tape[6] = '0' + ((now.second())/10);
  tape[7] = '0' + ((now.second())%10);
  
  tape[10] = '0' + ((now.day())/10); 
  tape[11] = '0' + ((now.day())%10);
  tape[13] = '0' + ((now.month())/10);
  tape[14] = '0' + ((now.month())%10);
  tape[16] = '0' + ((now.year())/1000);
  tape[17] = '0' + (((now.year())/100)%10);
  tape[18] = '0' + (((now.year())/10)%10);
  tape[19] = '0' + ((now.year())%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);    
}
/* Print time only */
char timeStr[8]; // enough space for "XX:XX:XX\0"
sprintf( timeStr, "%02d:%02d:%02d", now.hour(), now.minute(), now.second() );
matrix.print( timeStr );
matrix.write();

for(j=0;j<38;j++)
  {
   for(a=1;a<9;a++)
    Write_Max7219(a,disp1[j][a-1]);
   delay(200);

}
}code]
char timeStr[8]; // enough space for "XX:XX:XX\0"

I give up.

This part of your code takes over 7.6 seconds (7600 milliseconds of delay alone). That might explain why your seconds aren’t counting. At best they should jump every 7 or 8 seconds.

  for (j = 0; j < 38; j++)
  {
    for (a = 1; a < 9; a++)
      Write_Max7219(a, disp1[j][a - 1]);
    delay(200);
  }

Ok, what is wrong with the statement 'char timeStr[8]; // enough space for "XX:XX:XX\0"'. The array only has to hold '8' character.

"XX" times 3 = 6 characters ":" times 2 = 2 characters '\0' times 1 = 1 character 6 + 2 + 1 = ?

Ok my mistake, didn't think '\0' was used, even so if you change the '8' to '9' in message #13 the rest of the message still holds with true, time only is displayed once with no seconds counting. So its back to square one.

Having made the changes to the program , the seconds still do not display, this was the original reason for the question on the forum, has it now been put it the to hard basket.