Go Down

Topic: Changes to md_max72xx library? (Read 920 times) previous topic - next topic

austinibew145

Hello everyone. I have a project that I build a while back. It worked great. I had to reload the sketch to update the time. It was off about 20 min. I had trouble compiling. I got that fixed by using an older version. Now that I have uploaded the sketch the matrix doesn't work. I tried uploading the test example and it worked but was not scrolling properly. Looking into the h file to change the hardware I could not find the lines of code. I followed a few youtubers and it's like that section was removed. So I re downloaded it and it still wasn't there. So my question is... was there an update that changed that part of the code? Is there any fix? I uploaded my code in the programming question section under trouble uploading/compiling. I don't have access to upload anything from my pc today. Any help would be appreciated. I can upload the h file I have or whatever tomorrow night. I do have my pc just no internet.
Turbo Buick Enthusiast

pert

Please provide more details:

Which lines?

If I understand correctly, you are missing some lines which were in a newer version but are not in the older version, which you switched to because the newer version didn't compile for you. If so, the issue is not that the lines were removed, but that they were added.

Which versions are you talking about?

It seems to me that if you want the code that's in the newer version of the library, you would be best off to figure out the solution to the compilation error, rather than messing with some outdated version of the library.

Paul__B

If I Recall Correctly ("IIRC"), the older version required the display type (such as "FC-16") to be hard-coded into the ".h" file by commenting out all but the particular type declaration in use so that your projects were then all constrained to that type of display - which would mostly be the case.

But you should not have to fiddle about with the ".h" files, so this has now been changed to a #define in your main code file.  You will need to read Marco's instructions which come with the library, not thoroughly random YouTube postings.

austinibew145

Thanks Paul. That what I thought happened. I must have updated the code, but didn't realize there were changes like that. I will have to look for Marcos instructions. It makes sense to keep people out of the h files. If I was more proficient with this site I would link my other post. I will try to get on the pc in a little bit.
Turbo Buick Enthusiast

austinibew145

Get hub the best place to look?
Turbo Buick Enthusiast

marco_c

It changed to being specified in the object initialisation. Look at any of the examples for the changed syntax, or even look at the documentation in the docs folder.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

austinibew145

Finally on the PC. this is the code I was running. I spent a lot of time trying to figure out how to use the library. finally gave in and just modded  an example. tonight I played with the md_max72xxtest example. I was able to get it to work properly. #define HARDWARE_TYPE MD_MAX72XX::FC16_HW is this the only line I need to add/change? I aspire to one day understand how all of this works.

Code: [Select]
//Basically finished would like to play with messages at diffrent times

//got lunch time to work thinking add it to the time case so either display time or lunch time ect see project #8
//working good smooth transistions. changes formatting. added some case swithes to get mayas info in

//  Code modded from MD_zone_time_message in exampls of MD_Parola
//  also used code from DHT.h examples
// - DS1307 library (MD_DS1307) found at https://github.com/MajicDesigns/DS1307
// NOTE: MD_MAX72xx library must be installed and configured for the LED
// matrix type being used. Refer documentation included in the MD_MAX72xx
// library or see this link:
// https://majicdesigns.github.io/MD_MAX72XX/page_hardware.html
//

// connect real time clock to pins SCL to A5, SDA to A4, 5V, and GND.
// Connect pin 1 (on the left) of the  Tempsensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the Temp sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the Temp sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Use the DS1307 clock module
//#define USE_DS1307 0

// Header file includes
#include <MD_Parola.h>  //LED
#include <MD_MAX72xx.h> //LED
#include <SPI.h>        //LED
#include "Font_Data.h"  //LED

#include <MD_DS1307.h> //Clock
#include <Wire.h>      //Clock

#include "DHT.h"      //Temp sensor



// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define MAX_DEVICES 8  // Max devices attached

#define CLK_PIN   13  // Pin for led clock
#define DATA_PIN  11  // pin for led data in
#define CS_PIN    10  // Pin for led chip select

#define DHTPIN 2 // Pin for Temp sensor
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321

// Hardware SPI connection
MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES); //LED
DHT dht(DHTPIN, DHTTYPE); // Temp


#define SPEED_TIME  75 //LED
#define PAUSE_TIME  1000  //LED was 0

#define MAX_MESG  20  //LED

// Turn on debug statements to the serial output
#define DEBUG 0

// Global variables
float oldt =0;
float oldh =0;
float oldf =0;
float t=20;
float h=100;
float f=70;
int nan = nan;
int Red = 6; //Red led output pin
int Blue = 5; //Blue led output pin
int Green = 3; //Green led output pin

char szTime[9];    // mm:ss\0
char szMesg[MAX_MESG+1] = "";

uint8_t degC[] = { 6, 3, 3, 56, 68, 68, 68 }; // Deg C
uint8_t degF[] = { 6, 3, 3, 124, 20, 20, 4 }; // Deg F

char *mon2str(uint8_t mon, char *psz, uint8_t len)

// Get a label from PROGMEM into a char array
{
  static const __FlashStringHelper* str[] =
  {
    F("Jan"), F("Feb"), F("Mar"), F("Apr"),
    F("May"), F("Jun"), F("Jul"), F("Aug"),
    F("Sep"), F("Oct"), F("Nov"), F("Dec")
  };

  strncpy_P(psz, (const char PROGMEM *)str[mon-1], len);
  psz[len] = '\0';

  return(psz);
}

char *dow2str(uint8_t code, char *psz, uint8_t len)
{
  static const __FlashStringHelper* str[] =
  {
    F("Sunday"), F("Monday"), F("Tuesday"),
    F("Wednesday"), F("Thursday"), F("Friday"),
    F("Saturday"), F("Maya B Webb"), F("Radiochemist"),
    F("Lunch Time")
  };

  strncpy_P(psz, (const char PROGMEM *)str[code-1], len);
  psz[len] = '\0';

  return(psz);
}

void getTemp(){
   h = dht.readHumidity(); //read humidity
   t = dht.readTemperature();//read temperature in Celsius ()
   f = dht.readTemperature(true); //read tempeature in Fahrenheit (true)
     //Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    analogWrite (Green,200);
  }else{
    analogWrite (Green,0);
  }}

void getTime(char *psz, bool f = false)
// Code for reading clock time
{
//#if USE_DS1307
  RTC.readTime();
  sprintf(psz, "%02d%c%02d", RTC.h, (f ? ':' : ' '), RTC.m);
 
/*#else
  uint16_t  h, m, s;

  s = millis()/1000;
  m = s/60;
  h = m/60;
  m %= 60;
  s %= 60;
  sprintf(psz, "%02d%c%02d", h, (f ? ':' : ' '), m);
#endif*/
}

void getDate(char *psz)
// Code for reading clock date
{
//#if USE_DS1307
  char szBuf[10];

  RTC.readTime();
  sprintf(psz, "%d %s %04d", RTC.dd, mon2str(RTC.mm, szBuf, sizeof(szBuf)-1), RTC.yyyy);
//#else
//  strcpy(szMesg, "25 Dec 2017");
//#endif
}

void setup(void)
{
  Serial.begin(9600);
  pinMode (Red, OUTPUT); //red
  pinMode (Blue, OUTPUT); //blue
  pinMode (Green, OUTPUT); //green

  dht.begin();
  P.begin(1);
  P.setInvert(false);

  P.setZone(0, 0, MAX_DEVICES-1);
  //P.setZone(1, MAX_DEVICES-4, MAX_DEVICES-1);
  //P.setFont(1, numeric7Seg);
 
  P.displayZoneText(0, szMesg, PA_CENTER, SPEED_TIME, PAUSE_TIME, PA_SCROLL_LEFT, PA_SCROLL_LEFT);

  P.addChar('$', degC);
  P.addChar('&', degF);

//#if USE_DS1307
  RTC.control(DS1307_CLOCK_HALT, DS1307_OFF);
  RTC.control(DS1307_12H, DS1307_OFF);
//#endif

  getTime(szMesg);
}

void loop(void)
{

  static uint32_t lastTime = 0; // millis() memory
  static uint8_t  display = 0;  // current display mode
  static bool flasher = false;  // seconds passing flasher

  P.displayAnimate();

  if (P.getZoneStatus(0))
  {
    switch (display)
    {
      case 0: // first message name
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_WIPE);
        display++;
     
       dow2str(8 , szMesg, MAX_MESG); //made up shit to work
         break;
         
      case 1: // second message title
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_FADE);
        display++;
       dow2str(9 , szMesg, MAX_MESG); //made up shit to work
         break;
         

      case 2: // Temperature deg F
        P.setTextEffect(0, PA_SCROLL_UP, PA_SCROLL_LEFT);
        display++;
          if (f == nan){
           dtostrf(oldf, 3, 0, szMesg);
          strcat(szMesg, "&");
        }else{
          dtostrf(f, 3, 0, szMesg);
          strcat(szMesg, "&");
          oldf = f;
        }
     
        break;
       
      case 3: // Temperature deg C
        P.setTextEffect(0, PA_SCROLL_UP, PA_WIPE);
        display++;
         getTemp();
        if (t == nan){
           dtostrf(oldt, 3, 0, szMesg);
          strcat(szMesg, "$");
        }else{
          dtostrf(t, 3, 0, szMesg);
          strcat(szMesg, "$");
          oldt = t;
        }

        break;

      case 4: // Relative Humidity
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_DOWN);
        display++;
       
          if (h == nan){
           dtostrf(oldh, 3, 0, szMesg);
          strcat(szMesg, "%RH");
        }else{
          dtostrf(h, 3, 0, szMesg);
          strcat(szMesg, "% RH");
          oldh = h;
        }

        break;
    /* case 5: // time
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display++;
        getTime(szMesg, flasher);
         flasher = !flasher;
     
         break;

          case 6: //Lunch
      if(RTC.h == 13 && RTC.m == 37){   
     
         P.setTextEffect (0, PA_SCROLL_UP, PA_SCROLL_UP);
         display++;
          dow2str(10 , szMesg, MAX_MESG); //made up shit to work
      }else{
         P.setTextEffect (0, PA_SCROLL_UP, PA_SCROLL_UP);
         display++;
          dow2str(8 , szMesg, MAX_MESG); //made up shit to work
      }
         break;*/
     
      case 5: // day of week
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_UP);
        display++;
         

        dow2str(RTC.dow, szMesg, MAX_MESG);

        break;

      default:  // Calendar
        P.setTextEffect(0, PA_DISSOLVE, PA_DISSOLVE);
        display = 0;
 
        getDate(szMesg);
        break;
    }

    P.displayReset(0);
  }
  //Serial.println (h);
   if (RTC.h == 12 && RTC.m == 00){
    analogWrite (Green, 100);
   
   
  }else{
    analogWrite (Green, 0);
   
  }
 
     if (f < 70){   // LED blue if too cold
       analogWrite (Blue,200);
      }else{
        analogWrite (Blue,0);}
       

      if (f > 85){ // LED red if too hot
        analogWrite (Red, 200);
      }else{
        analogWrite (Red, 0);}
       
  // Finally, adjust the time string if we have to
 // if (millis() - lastTime >= 1000)
 // {
 //   lastTime = millis();
 //   getTime(szTime, flasher);
 //   flasher = !flasher;

 //   P.displayReset(0);
 // }
}
Turbo Buick Enthusiast

austinibew145

I don't know what the preferred method is for sharing videos. This is a link you my YouTube page. The video is of this project working in its early stages. https://youtu.be/cH1MC7aavgg
Turbo Buick Enthusiast

Paul__B

We can't embed YouTube in this forum, but you can make it a link.  :smiley-lol:

austinibew145

https://youtu.be/cH1MC7aavgg I tink I got the link in.

I looked through the code I uploaded, and compared it to the one I printed off when I finished the project. I then realized they are close but not the same. I don't think either one is working currently. I plan on making the hardware change to the printed code and see what happens. if that doesn't work I will try to go back to an older version.   
Turbo Buick Enthusiast

austinibew145

so burnt out for the night. I tried to get the old library installed, and get it to work that way. It did not. At this point I don't know what change. I just want to get it back on the wife's desk and forget it for a while. Any suggestions?

Code: [Select]
//Basically finished would like to play with messages at diffrent times
//got a green led to turn on at 1200 lunch adding a scrolling text would be nice
//got lunch time to work thinking add it to the time case so either display time or lunch time ect
//working good smooth transistions. changes formatting. added some case swithes to get mayas info in
// no working date time or temp
//replace comments inportant info
// Connect pin 1 (on the left) of the  Tempsensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the Temp sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the Temp sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Use the DS1307 clock module
#define USE_DS1307 0

// Header file includes
#include <MD_Parola.h>  //LED
#include <MD_MAX72xx.h> //LED
#include <SPI.h>        //LED
#include "Font_Data.h"  //LED

#include <MD_DS1307.h> //Clock
#include <Wire.h>      //Clock

#include "DHT.h"      //Temp sensor



// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 8  // Max devices attached

#define CLK_PIN   13  // Pin for led clock
#define DATA_PIN  11  // pin for led data in
#define CS_PIN    10  // Pin for led chip select

#define DHTPIN 2 // Pin for Temp sensor
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321

// Hardware SPI connection
MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES); //LED
DHT dht(DHTPIN, DHTTYPE); // Temp


#define SPEED_TIME  75 //LED
#define PAUSE_TIME  1000  //LED was 0

#define MAX_MESG  20  //LED

// Turn on debug statements to the serial output
#define DEBUG 0

// Global variables
float oldt =0;
float oldh =0;
float oldf =0;
float t=20;
float h=100;
float f=70;
int nan = nan;
int Red = 6; //Red led output pin
int Blue = 5; //Blue led output pin
int Green = 3; //Green led output pin

char szTime[9];    // mm:ss\0
char szMesg[MAX_MESG+1] = "";

uint8_t degC[] = { 6, 3, 3, 56, 68, 68, 68 }; // Deg C
uint8_t degF[] = { 6, 3, 3, 124, 20, 20, 4 }; // Deg F

char *mon2str(uint8_t mon, char *psz, uint8_t len)

// Get a label from PROGMEM into a char array
{
  static const __FlashStringHelper* str[] =
  {
    F("Jan"), F("Feb"), F("Mar"), F("Apr"),
    F("May"), F("Jun"), F("Jul"), F("Aug"),
    F("Sep"), F("Oct"), F("Nov"), F("Dec")
  };

  strncpy_P(psz, (const char PROGMEM *)str[mon-1], len);
  psz[len] = '\0';

  return(psz);
}

char *dow2str(uint8_t code, char *psz, uint8_t len)
{
  static const __FlashStringHelper* str[] =
  {
    F("Sunday"), F("Monday"), F("Tuesday"),
    F("Wednesday"), F("Thursday"), F("Friday"),
    F("Saturday"), F("Maya B Webb"), F("Radiochemist"),
    F("Lunch Time")
  };

  strncpy_P(psz, (const char PROGMEM *)str[code-1], len);
  psz[len] = '\0';

  return(psz);
}

void getTemp(){
   h = dht.readHumidity(); //read humidity
   t = dht.readTemperature();//read temperature in Celsius ()
   f = dht.readTemperature(true); //read tempeature in Fahrenheit (true)
     //Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    analogWrite (Green,200);
  }else{
    analogWrite (Green,0);
  }}

void getTime(char *psz, bool f = false)
// Code for reading clock time
{
//#if USE_DS1307
  RTC.readTime();
  sprintf(psz, "%02d%c%02d", RTC.h, (f ? ':' : ' '), RTC.m);
 
/*#else
  uint16_t  h, m, s;

  s = millis()/1000;
  m = s/60;
  h = m/60;
  m %= 60;
  s %= 60;
  sprintf(psz, "%02d%c%02d", h, (f ? ':' : ' '), m);
#endif*/
}

void getDate(char *psz)
// Code for reading clock date
{
//#if USE_DS1307
  char szBuf[10];

  RTC.readTime();
  sprintf(psz, "%d %s %04d", RTC.dd, mon2str(RTC.mm, szBuf, sizeof(szBuf)-1), RTC.yyyy);
//#else
//  strcpy(szMesg, "25 Dec 2017");
//#endif
}

void setup(void)
{
  Serial.begin(9600);
  pinMode (Red, OUTPUT); //red
  pinMode (Blue, OUTPUT); //blue
  pinMode (Green, OUTPUT); //green

  dht.begin();
  P.begin(1);
  P.setInvert(false);

  P.setZone(0, 0, MAX_DEVICES-1);
  //P.setZone(1, MAX_DEVICES-4, MAX_DEVICES-1);
  //P.setFont(1, numeric7Seg);
 
  P.displayZoneText(0, szMesg, PA_CENTER, SPEED_TIME, PAUSE_TIME, PA_SCROLL_LEFT, PA_SCROLL_LEFT);

  P.addChar('$', degC);
  P.addChar('&', degF);

//#if USE_DS1307
  RTC.control(DS1307_CLOCK_HALT, DS1307_OFF);
  RTC.control(DS1307_12H, DS1307_OFF);
//#endif

  getTime(szMesg);
}

void loop(void)
{

  static uint32_t lastTime = 0; // millis() memory
  static uint8_t  display = 0;  // current display mode
  static bool flasher = false;  // seconds passing flasher

  P.displayAnimate();

  if (P.getZoneStatus(0))
  {
    switch (display)
    {
      case 0: // first message name
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_UP);
        display++;
     
       dow2str(8 , szMesg, MAX_MESG); //made up shit to work
         break;
         
      case 1: // second message title
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display++;
       dow2str(9 , szMesg, MAX_MESG); //made up shit to work
         break;
         

      case 2: // Temperature deg F
        P.setTextEffect(0, PA_SCROLL_UP, PA_SCROLL_LEFT);
        display++;
          if (f == nan){
           dtostrf(oldf, 3, 0, szMesg);
          strcat(szMesg, "&");
        }else{
          dtostrf(f, 3, 0, szMesg);
          strcat(szMesg, "&");
          oldf = f;
        }
     
        break;
       
      case 3: // Temperature deg C
        P.setTextEffect(0, PA_SCROLL_UP, PA_SCROLL_RIGHT);
        display++;
         getTemp();
        if (t == nan){
           dtostrf(oldt, 3, 0, szMesg);
          strcat(szMesg, "$");
        }else{
          dtostrf(t, 3, 0, szMesg);
          strcat(szMesg, "$");
          oldt = t;
        }

        break;

      case 4: // Relative Humidity
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_DOWN);
        display++;
       
          if (h == nan){
           dtostrf(oldh, 3, 0, szMesg);
          strcat(szMesg, "%RH");
        }else{
          dtostrf(h, 3, 0, szMesg);
          strcat(szMesg, "% RH");
          oldh = h;
        }

        break;
     case 5: // time
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display++;
        getTime(szMesg, flasher);
         flasher = !flasher;
     
         break;

          case 6: //Lunch
      if(RTC.h == 12 && RTC.m <= 30){  //lunch time 
     
         P.setTextEffect (0, PA_SCROLL_UP, PA_SCROLL_UP);
         display++;
          dow2str(10 , szMesg, MAX_MESG); //made up shit to work. write statment in day of week and use that number in first spot
         
      }else if (RTC.h == 15 && RTC.m <= 15){//go home
          dow2str(10 , szMesg, MAX_MESG); //made up shit to work. write statment in day of week and use that number in first spot
         
      }else{ //display time
         P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display++;
        getTime(szMesg, flasher);
         flasher = !flasher;
       
      }
     
         break;
     
      case 7: // day of week
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_UP);
        display++;
         

        dow2str(RTC.dow, szMesg, MAX_MESG);

        break;

      default:  // Calendar
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_UP);
        display = 0;
 
        getDate(szMesg);
        break;
    }

    P.displayReset(0);
  }
  Serial.println (h);
   if (RTC.h == 12 && RTC.m == 00){
    analogWrite (Green, 50);
    analogWrite (Red, 50);
   
  }else{
    analogWrite (Green, 0);
    analogWrite (Red, 0);
  }
 
     if (f < 70){   // LED blue if too cold
       analogWrite (Blue,200);
      }else{
        analogWrite (Blue,0);}
       

      if (f > 85){ // LED red if too hot
        analogWrite (Red, 200);
      }else{
        analogWrite (Red, 0);}
       
  // Finally, adjust the time string if we have to
 // if (millis() - lastTime >= 1000)
 // {
 //   lastTime = millis();
 //   getTime(szTime, flasher);
 //   flasher = !flasher;

 //   P.displayReset(0);
 // }
}
Turbo Buick Enthusiast

austinibew145

I did re install the updated library's and ran some of the examples. They work fine.
Turbo Buick Enthusiast

austinibew145

On the way home last night I thought... just do what I did the first time. So I compared the code I was using to the updated example. I got it working, sort of... moving in the right direction anyway.
Turbo Buick Enthusiast

austinibew145

So I did get things working. The updated Library is a lot easier to understand. Or at least manipulate. I am having Trouble with the DS 1307 RTC. It is way off like an hour and a half. I tried setting my computers clock just to be sure its right. my computer is set to auto update the time. I don't get why its off. I was going to make a new post but Ill start here. I searched the issue, but only saw people who had issues with it being 30 seconds off, or there computer having the wrong time.

Updated code:

Code: [Select]
// Program to demonstrate the MD_Parola library
//
// Display the time in one zone and other information scrolling through in
// another zone.
// - Time is shown in a user defined fixed width font
// - Scrolling text uses the default font
// - Temperature display uses user defined characters
// - Optional use of DS1307 module for time and DHT11 sensor for temp and humidity
// - DS1307 library (MD_DS1307) found at https://github.com/MajicDesigns/DS1307
// - DHT11 library (DHT11_lib) found at http://arduino.cc/playground/Main/DHT11Lib
// - MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
//

// Use the DHT11 temp and humidity sensor
#define USE_DHT11 0

// Use the DHT22 temp and humidity sensor
#define USE_DHT22 1

// Use the DS1307 clock module
#define USE_DS1307 1

// Header file includes
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

#include "Font_Data.h"

// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 8

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


#if USE_DHT11
#include <dht11.h>

#define DHT11_PIN 2

dht11 DHT11;
#endif

#if USE_DHT22
  #include "DHT.h" //temp lib
  #define DHTPIN 2 //pin for sensor
  #define DHTTYPE DHT22 // DHT22 (AM2302),AM2321
  DHT dht(DHTPIN, DHTTYPE); //TEMP
#endif

#if USE_DS1307
#include <MD_DS1307.h>
#include <Wire.h>
#endif

// Hardware SPI connection
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// Arbitrary output pins
// MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

#define SPEED_TIME  75
#define PAUSE_TIME  0

#define MAX_MESG  20

// Turn on debug statements to the serial output
#define DEBUG 0

// Global variables
float oldt = 0; //temp?
float oldh = 0; //temp?
float oldf = 0; //temp?
float t = 20;
float h = 100;
float f = 70;
int nan = nan;
int Red = 6; //Red led output pin
int Blue = 5; //Blue led output pin
int Green = 3; //Green led output pin

char szTime[9];    // mm:ss\0
char szMesg[MAX_MESG+1] = "";

uint8_t degC[] = { 6, 3, 3, 56, 68, 68, 68 }; // Deg C
uint8_t degF[] = { 6, 3, 3, 124, 20, 20, 4 }; // Deg F

char *mon2str(uint8_t mon, char *psz, uint8_t len)
// Get a label from PROGMEM into a char array
{
  static const char str[][4] PROGMEM =
  {
    "Jan", "Feb", "Mar", "Apr", "May", "Jun",
    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
  };

  *psz = '\0';
  mon--;
  if (mon < 12)
  {
    strncpy_P(psz, str[mon], len);
    psz[len] = '\0';
  }

  return(psz);
}

char *dow2str(uint8_t code, char *psz, uint8_t len)
{
  static const char str[][10] PROGMEM =
  {
    "Sunday", "Monday", "Tuesday", "Wednesday",
    "Thursday", "Friday", "Saturday"
  };

  *psz = '\0';
  code--;
  if (code < 7)
  {
    strncpy_P(psz, str[code], len);
    psz[len] = '\0';
  }

  return(psz);
}

void getTemp(){
  #if USE_DHT22
   h = dht.readHumidity(); //read humidity
   t = dht.readTemperature();//read temperature in Celsius ()
   f = dht.readTemperature(true); //read tempeature in Fahrenheit (true)
     //Check if any reads failed and exit early (to try again).
     if (isnan(h) || isnan(t) || isnan(f)) {
        analogWrite (Green,200);
    }else{
        analogWrite (Green,0);
   
  }
  #endif
  }
 
void getTime(char *psz, bool f = true)
// Code for reading clock time
{
#if USE_DS1307
  RTC.readTime();
  sprintf(psz, "%02d%c%02d", RTC.h, (f ? ':' : ' '), RTC.m);
#else
  uint16_t  h, m, s;

  s = millis()/1000;
  m = s/60;
  h = m/60;
  m %= 60;
  s %= 60;
  sprintf(psz, "%02d%c%02d", h, (f ? ':' : ' '), m);
#endif
}

void getDate(char *psz)
// Code for reading clock date
{
#if USE_DS1307
  char  szBuf[10];

  RTC.readTime();
  sprintf(psz, "%d %s %04d", RTC.dd, mon2str(RTC.mm, szBuf, sizeof(szBuf)-1), RTC.yyyy);
#else
  strcpy(szMesg, "29 Feb 2016");
#endif
}

void setup(void)
{
  Serial.begin(9600);
  pinMode (Red, OUTPUT); //red
  pinMode (Blue, OUTPUT); //blue
  pinMode (Green, OUTPUT); //green
 
  P.begin(2);
  P.setInvert(false);

  P.setZone(0, 0, MAX_DEVICES-1);
  //P.setZone(1, MAX_DEVICES-4, MAX_DEVICES-1);
  P.setFont(1, numeric7Seg);

  //P.displayZoneText(1, szTime, PA_CENTER, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
  P.displayZoneText(0, szMesg, PA_CENTER, SPEED_TIME, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);

  P.addChar('$', degC);
  P.addChar('&', degF);

#if USE_DS1307
  RTC.control(DS1307_CLOCK_HALT, DS1307_OFF);
  RTC.control(DS1307_12H, DS1307_OFF);
#endif

  getTime(szTime);
}

void loop(void)
{
  static uint32_t lastTime = 0; // millis() memory
  static uint8_t  display = 0;  // current display mode
  static bool flasher = false;  // seconds passing flasher

  P.displayAnimate();

  if (P.getZoneStatus(0))
  {
    switch (display)
    {
 
       
         case 0: // name
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display++;

        strcpy(szMesg, "Maya B Webb");

        break;
       
    case 1: // Position
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display++;


        strcpy(szMesg, "Radiochemist");

        break;
       
          case 2: // Temperature deg C
        P.setTextEffect(0, PA_SCROLL_UP, PA_SCROLL_UP);
        display++;
#if USE_DHT11
        if (DHT11.read(DHT11_PIN) == 0)
        {
          dtostrf(DHT11.temperature, 3, 1, szMesg);
          strcat(szMesg, "$");
        }
#else
        strcpy(szMesg, "22.0$");
#endif
        break;
      case 3: // Temperature deg F
        P.setTextEffect(0, PA_SCROLL_UP, PA_SCROLL_UP);
        display++;
#if USE_DHT11
        if (DHT11.read(DHT11_PIN) == 0)
        {
          dtostrf((1.8 * DHT11.temperature)+32, 3, 1, szMesg);
          strcat(szMesg, "&");
        }
#else
        strcpy(szMesg, "71.6&");
#endif
        break;

      case 4: // Relative Humidity
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display++;
#if USE_DHT11
        if (DHT11.read(DHT11_PIN) == 0)
        {
          dtostrf(DHT11.humidity, 3, 0, szMesg);
          strcat(szMesg, "% RH");
        }
#else
        strcpy(szMesg, "36 % RH");
#endif
        break;

      case 5: // time
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display++;
      #if  USE_DS1307
        getTime(szMesg, flasher);
         flasher = !flasher;
      #endif
         break;
         
      case 6: // day of week
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display++;
#if USE_DS1307
        dow2str(RTC.dow, szMesg, MAX_MESG);
#else
        dow2str(4, szMesg, MAX_MESG);
#endif
        break;

      default:  // Calendar
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display = 0;
        getDate(szMesg);
        break;
    }

    P.displayReset(0);
  }

  // Finally, adjust the time string if we have to
 /* if (millis() - lastTime >= 1000)
  {
    lastTime = millis();
    getTime(szTime, flasher);
    flasher = !flasher;

    P.displayReset(1);
  }*/
}
Turbo Buick Enthusiast

Dancopy

Hello austinibew145!
Did you solve your problem?
I think your sketch is identical to a code from MD_Parola> Parola_Zone_TimeMsg,
which I used with two display modules (blue + red) to show Time and Date scrolling here:
https://www.youtube.com/watch?v=ia_ZV6i7Ro4&feature=youtu.be

Go Up