Issues in digital clock using LED Matrix display with animation effects

Hi everyone,

I am trying to build a LED clock using Arduino Nano, DS1307 RTC , LED matrix display.

I have succeeded in displaying the time and date as per the code sourced from many forums .

My requirements are that :

  1. Time should be displayed. (Currently the seconds part is not fully visible due to the display being only 4 LED matrix units)

  2. Current date to be displayed after an animation like "FADE". (Currently the year part is not fully visible due to the display being only 4 LED matrix units. Eg: 26/12 is only visible instead of 26/12/2017)

  3. Temperature (LM35), Day and Month name to be displayed after an animation like "SLICE". (Not yet started).

The main issue is that although the time is being displayed I am facing difficulty in making the "timeStamp" into an animation effect as per the MD_Parola catalog.

Any guidance would be much appreciated.

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib

#include <Wire.h>
#include <MD_DS1307.h>
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include <RTClib.h>


#define MAX_DEVICES 4
#define CLK_PIN   13
#define DATA_PIN  11
#define CS_PIN    10

RTC_DS1307 rtc;

MD_Parola P = MD_Parola(DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
//MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES);

void setup () 
{

  Wire.begin();
  Serial.begin(57600);
  P.begin();
  

  
 if(! rtc.begin()) 
  {
    Serial.println("Couldn't find RTC");
    while (1);
  }

 if(! rtc.isrunning()) 
  {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
     rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    
  }

}
void loop () 

{

 

DateTime now = rtc.now();
     
char timeStamp[15];
char dateStamp[15];


if(now.hour() > 12)

{
  
  int h = now.hour() - 12 ;
  
 
sprintf(timeStamp, "%d:%d:%d", h ,now.minute(), now.second());
}


Serial.println(timeStamp);

    
sprintf(dateStamp, "%d/%d/%d",  now.day(),now.month(),now.year());   
  
Serial.println(dateStamp);

 
P.print(timeStamp);

if (now.second() == 25 | now.second() == 35)

{
  
P.print(dateStamp);

delay(5000);

}

delay(1000);

}

#define SPEED_TIME 25
#define PAUSE_TIME 2000

P.displayText(timeStamp, CENTER, SPEED_TIME, PAUSE_TIME, SCROLL_LEFT, SCROLL_RIGHT);
P.displayAnimate();

OR

P.displayText(timeStamp, SPEED_TIME,PAUSE_TIME,PA_SLICE);
P.displayAnimate();

Since i am typing from my mobile I am unable to add these and see the endresult. So i am asking the Gurus if I can get any animation using the above lines?

Or am i missing anything here.

I just want to add animation to the time displayed in the matrix display.

This is the one which I did. Hope someone can simplify it if needed.

#include <Wire.h>
#include <MD_DS1307.h>
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include <RTClib.h>


#define MAX_DEVICES 4
#define CLK_PIN   13
#define DATA_PIN  11
#define CS_PIN    10


#define MAX_DEVICES 4

#define PAUSE_TIME    3000
#define SCROLL_SPEED  30


RTC_DS1307 rtc;

//MD_Parola P = MD_Parola(DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES);

void setup () 
{

  Wire.begin();
  Serial.begin(57600);
  P.begin();
  
 if(! rtc.begin()) 
  {
    Serial.println("Couldn't find RTC");
    while (1);
  }

 if(! rtc.isrunning()) 
  {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
     rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    
  }

}
void loop () 

{

DateTime now = rtc.now();
     
char timeStamp[15];
char dateStamp[15];



sprintf(timeStamp, "%02d:%02d", now.hour() ,now.minute());

Serial.println(timeStamp);
    
sprintf(dateStamp, "%02d/%02d",  now.day(),now.month());   
  
Serial.println(dateStamp);



 for (uint8_t i=0; i<ARRAY_SIZE(timeStamp); i++)
 
    {
P.displayText(timeStamp, PA_CENTER, SCROLL_SPEED, PAUSE_TIME, PA_PRINT, PA_MESH);
P.displayAnimate();

 while (!P.displayAnimate())
      
      ;
    
      break;
      
    }
    
 for (uint8_t q=0; q<ARRAY_SIZE(timeStamp); q++)
 
    {



 int dow = now.dayOfTheWeek();                
 char *d   ;                          
  switch(dow)
  {
     case 1:
     Serial.println("MON");
     d = "MON";
    
     break;
     
     case 2:
     Serial.println("TUE");
    
    d = "TUE";
 
     break;
     case 3:
     
     Serial.println("WED");
     

  d = "WED";
  
     break;
     case 4:
     
     Serial.println("THU");
     
    d = "THU";
    
     break;
     case 5:
     
     Serial.println("FRI");
     
   d = "FRI";
   
     break;
     case 6:
   Serial.println("SAT");
  
   d = "SAT";
   
     break;
     case 0:
     
     Serial.println("SUN");
     
   d = "SUN";
     break;
     }
    

P.displayText(d, PA_CENTER, SCROLL_SPEED, PAUSE_TIME, PA_PRINT, PA_BLINDS);
P.displayAnimate();

 while (!P.displayAnimate())
      
      ;
    
      break;
      
    }



for (uint8_t j=0; j<ARRAY_SIZE(dateStamp); j++)
{

 P.displayText(dateStamp, PA_CENTER, SCROLL_SPEED, PAUSE_TIME, PA_PRINT, PA_SCROLL_LEFT);
   
     
      while (!P.displayAnimate())
      
      ;
    
      break;
      
    }


for (uint8_t r=0; r<ARRAY_SIZE(dateStamp); r++)
 
    {


 int moy = now.month();                
 char *e   ;    
                      
  switch(moy)
  {
     case 1:
     Serial.println("JAN");
    e = "JAN";
    
     break;
     
     case 2:
     Serial.println("FEB");
    
   e = "FEB";
 
     break;

     case 3:
     
     Serial.println("MAR");
     

  e = "MAR";
  
     break;

     case 4:
     
     Serial.println("APR");
     
    e = "APR";
    
     break;

     case 5:
     
     Serial.println("MAY");
     
   e = "MAY";
   
     break;


     case 6:
   Serial.println("JUN");
  
   e = "JUN";
   
     break;

     case 7:
     
     Serial.println("JUL");
     
   e = "JUL";
     break;


case 8:
     
     Serial.println("AUG");
     
   e = "AUG";
     break;

case 9:
     
     Serial.println("SEP");
     
   e = "SEP";
     break;

case 10:
     
     Serial.println("OCT");
     
   e = "OCT";
     break;

case 11:
     
     Serial.println("NOV");
     
   e = "NOV";
     break;

case 12:
     
     Serial.println("DEC");
     
   e = "DEC";
     break;

     }
    

P.displayText(e, PA_CENTER, SCROLL_SPEED, PAUSE_TIME, PA_PRINT, PA_SCAN_HORIZ);
P.displayAnimate();

 while (!P.displayAnimate())
      
      ;
    
      break;
      
    }

 
for (uint8_t k=0; k<ARRAY_SIZE(dateStamp); k++)
{
  int iVarToCast = now.year();
  char buffer[4];
  dtostrf(iVarToCast, 4, 0, buffer);
  

P.displayText(buffer, PA_CENTER, SCROLL_SPEED, PAUSE_TIME, PA_PRINT, PA_SCROLL_LEFT);
Serial.println(buffer);

 while (!P.displayAnimate())
      
      ;
    
      break;
      
    }
}

vijithcv:
This is the one which I did. Hope someone can simplify it if needed.

Everything works except two issues.

  1. The Week and Month name is clipped if I use the scroll function. Eg: It shows only Januar and while it scrolls it doesn't display the remaining.

  2. The seconds doesn't increment while I enable the Parola scroll or any other animation. Its like the current second is saved in the char array and its displaying that value at that instant only.

I added a LM35 Sensor and I face the same issue wherein the temperature is not displayed real time. If there is any increase in temperature its displayed in the next animation sequence. Its also like frozen.

I think when the value is put into a char array and while using Parola library it shows the value as a word and any change in the value is shown in the next cycle of animation.

I hope i made my problem little bit clear.

Anyway it keeps the time and temperature day and date properly. Only minus I am not getting a live display.