I have 3 separated codes for my project but when i try to make them together i keep getting no sense errors that didnt't show before

#include <SPI.h>
#include <DMD.h>
#include <TimerOne.h>
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#define ROW_MODULE 2
#define COLUMN_MODULE 1
DMD p10(ROW_MODULE, COLUMN_MODULE);

char message[200];
char char_read;
byte pos_index = 0;
int i;
char welcome_screen[] = "Ready";

void p10scan()
{
p10.scanDisplayBySPI();
}

void setup()
{
Timer1.initialize(2000);
Timer1.attachInterrupt(p10scan);
p10.clearScreen( true );
Serial.begin(9600);
strcpy(message,welcome_screen);
}
void loop()
{

if(Serial.available())
{
for(i=0; i<199; i++)
{
message[i] = '\0';
Serial.print(message[i]);
}
pos_index=0;
}

while(Serial.available() > 0)
{
   p10.clearScreen( true );
   if(pos_index < (199)) 
   {         
       char_read = Serial.read();
       message[pos_index] = char_read;
       pos_index++;      
   } 

}

p10.selectFont(Arial_Black_16);
p10.drawMarquee(message ,200,(32*ROW_MODULE)-1,0);
long start=millis();
long timer_start=start;
boolean flag=false;
while(!flag)
{
if ((timer_start+30) < millis())
{
flag=p10.stepMarquee(-1,0);
timer_start=millis();
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "RTClib.h"
#include <SPI.h>
#include <DMD.h>
#include <TimerOne.h>
#include "SystemFont5x7.h"
#define DISPLAYS_ACROSS 2 //-> Number of P10 panels used, side to side.
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);

RTC_DS1307 rtc; //-> RTC Declaration

int _day, _month, _year, _hour24, _hour12, _minute, _second, _dtw;
int hr24;
String st;
char nameoftheday[7][12] = {"Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"};
char month_name[12][12] = {"Janvier","Fevrier", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Decembre"};

const long interval = 1000; //-> Retrieve time and date data every 1 second
unsigned long previousMillis = 0;

const long interval_for_date = 100; //-> For scroll speed
unsigned long previousMillis_for_date = 0;
char hr_24 [3];
String str_hr_24;
char mn [3];
String str_mn;
char sc [3];
String str_sc;

String strSecondRow;
char chrSecondRow[60];
int p=32;
int j;
int sr=1;

void ScanDMD() {
dmd.scanDisplayBySPI();
}

void setup() {
Serial.begin(115200);
Serial.println("Arduino RTC DS1307");
delay(1000);

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 (Set the time and date based on your computer time and date)
// rtc.adjust(DateTime(F(DATE), F(TIME))); //-> Set the time and date based on your computer time and date. If that doesn't work, use this line of code outside of "if (! rtc.isrunning())"
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
// following line sets the RTC to the date & time this sketch was compiled (Set the time and date based on your computer time and date)
//rtc.adjust(DateTime(F(DATE), F(TIME))); //-> Set the time and date based on your computer time and date. Use this line of code if it doesn't work in "if (! rtc.isrunning())"
//rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
// If the time and date are successfully set, then deactivate the code line (make the code a comment), then re-upload the code.
// if not done then the time and date will return to the beginning when it was set when arduino is reset or restarted.

Timer1.initialize(1000);
Timer1.attachInterrupt(ScanDMD);
dmd.clearScreen(true);
dmd.selectFont(SystemFont5x7);
}

void loop() {

unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis; //-> save the last time

GetDateTime(); //-> Retrieve time and date data from DS1307


str_hr_24=String(_hour24);
str_hr_24.toCharArray(hr_24,3);

if (_hour24<10) {
  dmd.drawString(2, 0, "0", 1, GRAPHICS_NORMAL);
  dmd.drawString(8, 0, hr_24, 1, GRAPHICS_NORMAL);
}
else {
  dmd.drawString(2, 0, hr_24, 2, GRAPHICS_NORMAL);
}



GetDateTime(); //-> Retrieve time and date data from DS1307
if (_second %2 == 0) {
  dmd.drawString(14, 0, ":", 2, GRAPHICS_OR);
}
else {
  dmd.drawString(14, 0, ":", 2, GRAPHICS_NOR);
}



str_mn=String(_minute);
str_mn.toCharArray(mn,3);

if (_minute<10) {
  dmd.drawString(19, 0, "0", 1, GRAPHICS_NORMAL);
  dmd.drawString(25, 0, mn, 1, GRAPHICS_NORMAL);
}
else {
  dmd.drawString(19, 0, mn, 2, GRAPHICS_NORMAL);
}

}

unsigned long currentMillis_for_date = millis();
if (currentMillis_for_date - previousMillis_for_date >= interval_for_date) {
previousMillis_for_date = currentMillis_for_date; //-> save the last time

switch (sr) {
case 1:
  strSecondRow = String(nameoftheday[_dtw]) + ", " + String(_day) + "-" + String(month_name[_month-1]) + "-" + String(_year);
  strSecondRow.toCharArray(chrSecondRow,60);
  j=strlen(chrSecondRow)+(strlen(chrSecondRow)*5);
  break;
case 2:
  strSecondRow.toCharArray(chrSecondRow,60);
  j=strlen(chrSecondRow)+(strlen(chrSecondRow)*5);
  break;
}

p--;
dmd.drawString(p, 9, chrSecondRow, strlen(chrSecondRow), GRAPHICS_NORMAL);
if (p<=~j) {
  p=32;
  sr++;
  if (sr>2) sr=1;
}

}
}
void GetDateTime() {
DateTime now = rtc.now();
_day=now.day();
_month=now.month();
_year=now.year();
_hour24=now.hour();
_minute=now.minute();
_second=now.second();
_dtw=now.dayOfTheWeek();

hr24=_hour24;
if (hr24>12) {
_hour12=hr24-12;
}
else if (hr24==0) {
_hour12=12;
}
else {
_hour12=hr24;
}

if (hr24<12) {
st="AM";
}
else {
st="PM";
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
those are the 3 codes that i cannot combined them together

int x =0;
int hr1,hr12;

#include<dht.h>
#define dht_apin 5
dht DHT;
int temp,hum;
#include <SPI.h>
#include <DMD.h>
#include <TimerOne.h>
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#define DISPLAYS_ACROSS 2
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
void ScanDMD()
{
dmd.scanDisplayBySPI();
}

void setup()
{
Serial.begin(9600);
DHT.read11(dht_apin);
temp = DHT.temperature;
hum = DHT.humidity;
Serial.println(DHT.temperature);
Serial.println(hum);
delay(6000);
Timer1.initialize( 5000 );
Timer1.attachInterrupt( ScanDMD );
dmd.clearScreen( true );
Serial.begin(9600);

}

void loop()
{
// DHT.read11(dht_apin);
// temp = DHT.temperature;
// hum = DHT.humidity;
//Serial.println(DHT.temperature);
//Serial.println(hum);
//delay(2000);

char t [3];
String str2;
str2=String(temp);
str2.toCharArray(t,3);
char h [3];
String str3;
str3=String(hum);
str3.toCharArray(h,3);

 dmd.clearScreen( true );
 dmd.selectFont(System5x7);
 for (byte x=0;x<DISPLAYS_ACROSS;x++) {
 for (byte y=0;y<DISPLAYS_DOWN;y++)   {
 dmd.drawString(  0+(32*x),  0+(16*y), "T:", 2, GRAPHICS_NORMAL );
 dmd.drawString(  0+(32*x),  9+(16*y), "H:", 2, GRAPHICS_NORMAL );
 }
 }

 dmd.selectFont(System5x7);
 for (byte x=0;x<DISPLAYS_ACROSS;x++) {
 for (byte y=0;y<DISPLAYS_DOWN;y++)   {
 dmd.drawString(  11+(32*x),  0+(16*y), t, 3, GRAPHICS_NORMAL );
 dmd.drawString(  11+(32*x),  9+(16*y), h, 3, GRAPHICS_NORMAL );
 }
 }

 dmd.drawCircle( 24,  1,  1, GRAPHICS_NORMAL );
 
 dmd.selectFont(System5x7);
 for (byte x=0;x<DISPLAYS_ACROSS;x++) {
 for (byte y=0;y<DISPLAYS_DOWN;y++)   {
 dmd.drawString(  27+(32*x),  0+(16*y), "C", 2, GRAPHICS_NORMAL );
 dmd.drawString(  27+(32*x),  9+(16*y), "%", 2, GRAPHICS_NORMAL );
 }
 }

 delay(5000);

}
///////////////////////////////////////////////////
this is the last one

Read the forum guidelines to see how to properly post code and some information on how to get the most from this forum.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

You can go back and fix your original posts by highlighting the code and clicking the </> in the menu bar.
code tags new

Please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

Please show your attempt to combine them. Use code tags as requested.

Please post your errors. Again, use code tags for that.

Which "dht.h" library are you using?

It looks like the 'DHT.h' library was an ancient version of the Adafruit DHT library which has since been re-written.

After finding the libraries and fixing some problems I was able to get it to compile without lots of warnings. Of course you can't have three functions named "setup" and three named "loop".

#include <SPI.h>
#include <DMD.h>
#include <TimerOne.h>
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#define ROW_MODULE 2
#define COLUMN_MODULE 1
DMD p10(ROW_MODULE, COLUMN_MODULE);

char message[200];
char char_read;
byte pos_index = 0;
int i;
char welcome_screen[] = "Ready";

void p10scan()
{
  p10.scanDisplayBySPI();
}

void setup1()
{
  Timer1.initialize(2000);
  Timer1.attachInterrupt(p10scan);
  p10.clearScreen( true );
  Serial.begin(9600);
  strcpy(message, welcome_screen);
}
void loop1()
{

  if (Serial.available())
  {
    for (i = 0; i < 199; i++)
    {
      message[i] = '\0';
      Serial.print(message[i]);
    }
    pos_index = 0;
  }

  while (Serial.available() > 0)
  {
    p10.clearScreen( true );
    if (pos_index < (199))
    {
      char_read = Serial.read();
      message[pos_index] = char_read;
      pos_index++;
    }
  }

  p10.selectFont(Arial_Black_16);
  p10.drawMarquee(message , 200, (32 * ROW_MODULE) - 1, 0);
  unsigned long start = millis();
  unsigned long timer_start = start;
  boolean flag = false;
  while (!flag)
  {
    if ((timer_start + 30) < millis())
    {
      flag = p10.stepMarquee(-1, 0);
      timer_start = millis();
    }
  }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "RTClib.h"
#include <SPI.h>
#include <DMD.h>
#include <TimerOne.h>
#include "SystemFont5x7.h"
#define DISPLAYS_ACROSS 2 //-> Number of P10 panels used, side to side.
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);

RTC_DS1307 rtc; //-> RTC Declaration

int _day, _month, _year, _hour24, _hour12, _minute, _second, _dtw;
int hr24;
String st;
char nameoftheday[7][12] = {"Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"};
char month_name[12][12] = {"Janvier", "Fevrier", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Decembre"};

const long interval = 1000; //-> Retrieve time and date data every 1 second
unsigned long previousMillis = 0;

const long interval_for_date = 100; //-> For scroll speed
unsigned long previousMillis_for_date = 0;
char hr_24 [3];
String str_hr_24;
char mn [3];
String str_mn;
char sc [3];
String str_sc;

String strSecondRow;
char chrSecondRow[60];
int p = 32;
int j;
int sr = 1;

void ScanDMD()
{
  dmd.scanDisplayBySPI();
}

void setup2()
{
  Serial.begin(115200);
  Serial.println("Arduino RTC DS1307");
  delay(1000);

  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 (Set the time and date based on your computer time and date)
    // rtc.adjust(DateTime(F(DATE), F(TIME))); //-> Set the time and date based on your computer time and date. If that doesn't work, use this line of code outside of "if (! rtc.isrunning())"
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
  // following line sets the RTC to the date & time this sketch was compiled (Set the time and date based on your computer time and date)
  //rtc.adjust(DateTime(F(DATE), F(TIME))); //-> Set the time and date based on your computer time and date. Use this line of code if it doesn't work in "if (! rtc.isrunning())"
  //rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  // If the time and date are successfully set, then deactivate the code line (make the code a comment), then re-upload the code.
  // if not done then the time and date will return to the beginning when it was set when arduino is reset or restarted.

  Timer1.initialize(1000);
  Timer1.attachInterrupt(ScanDMD);
  dmd.clearScreen(true);
  dmd.selectFont(SystemFont5x7);
}

void loop2()
{

  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval)
  {
    previousMillis = currentMillis; //-> save the last time

    GetDateTime(); //-> Retrieve time and date data from DS1307


    str_hr_24 = String(_hour24);
    str_hr_24.toCharArray(hr_24, 3);

    if (_hour24 < 10)
    {
      dmd.drawString(2, 0, "0", 1, GRAPHICS_NORMAL);
      dmd.drawString(8, 0, hr_24, 1, GRAPHICS_NORMAL);
    }
    else
    {
      dmd.drawString(2, 0, hr_24, 2, GRAPHICS_NORMAL);
    }



    GetDateTime(); //-> Retrieve time and date data from DS1307
    if (_second % 2 == 0)
    {
      dmd.drawString(14, 0, ":", 2, GRAPHICS_OR);
    }
    else
    {
      dmd.drawString(14, 0, ":", 2, GRAPHICS_NOR);
    }



    str_mn = String(_minute);
    str_mn.toCharArray(mn, 3);

    if (_minute < 10)
    {
      dmd.drawString(19, 0, "0", 1, GRAPHICS_NORMAL);
      dmd.drawString(25, 0, mn, 1, GRAPHICS_NORMAL);
    }
    else
    {
      dmd.drawString(19, 0, mn, 2, GRAPHICS_NORMAL);
    }
  }

  unsigned long currentMillis_for_date = millis();
  if (currentMillis_for_date - previousMillis_for_date >= interval_for_date)
  {
    previousMillis_for_date = currentMillis_for_date; //-> save the last time

    switch (sr)
    {
      case 1:
        strSecondRow = String(nameoftheday[_dtw]) + ", " + String(_day) + "-" + String(month_name[_month - 1]) + "-" + String(_year);
        strSecondRow.toCharArray(chrSecondRow, 60);
        j = strlen(chrSecondRow) + (strlen(chrSecondRow) * 5);
        break;
      case 2:
        strSecondRow.toCharArray(chrSecondRow, 60);
        j = strlen(chrSecondRow) + (strlen(chrSecondRow) * 5);
        break;
    }

    p--;
    dmd.drawString(p, 9, chrSecondRow, strlen(chrSecondRow), GRAPHICS_NORMAL);
    if (p <= ~j)
    {
      p = 32;
      sr++;
      if (sr > 2) sr = 1;
    }
  }
}
void GetDateTime()
{
  DateTime now = rtc.now();
  _day = now.day();
  _month = now.month();
  _year = now.year();
  _hour24 = now.hour();
  _minute = now.minute();
  _second = now.second();
  _dtw = now.dayOfTheWeek();

  hr24 = _hour24;
  if (hr24 > 12)
  {
    _hour12 = hr24 - 12;
  }
  else if (hr24 == 0)
  {
    _hour12 = 12;
  }
  else
  {
    _hour12 = hr24;
  }

  if (hr24 < 12)
  {
    st = "AM";
  }
  else
  {
    st = "PM";
  }
}

////////////////////////////////////////////////

int x = 0;
int hr1, hr12;

#include <DHT.h>

#define dht_apin 2

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

DHT dht(dht_apin, DHTTYPE);

int temp, hum;
#include <SPI.h>
#include <DMD.h>
#include <TimerOne.h>
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#define DISPLAYS_ACROSS 2
#define DISPLAYS_DOWN 1
// DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
//void ScanDMD()
//{
//  dmd.scanDisplayBySPI();
//}

void setup3()
{
  Serial.begin(9600);
  // DHT.read11(dht_apin);
  // temp = DHT.temperature;
  // hum = DHT.humidity;
  dht.read();
  temp = dht.readTemperature();
  hum = dht.readHumidity();
  
  Serial.println(temp);
  Serial.println(hum);

  delay(6000);
  Timer1.initialize( 5000 );
  Timer1.attachInterrupt( ScanDMD );
  dmd.clearScreen( true );
  Serial.begin(9600);

}

void loop3()
{
  // DHT.read11(dht_apin);
  // temp = DHT.temperature;
  // hum = DHT.humidity;
  //Serial.println(DHT.temperature);
  //Serial.println(hum);
  //delay(2000);

  char t [3];
  String str2;
  str2 = String(temp);
  str2.toCharArray(t, 3);
  char h [3];
  String str3;
  str3 = String(hum);
  str3.toCharArray(h, 3);

  dmd.clearScreen( true );
  dmd.selectFont(System5x7);
  for (byte x = 0; x < DISPLAYS_ACROSS; x++)
  {
    for (byte y = 0; y < DISPLAYS_DOWN; y++)
    {
      dmd.drawString(  0 + (32 * x),  0 + (16 * y), "T:", 2, GRAPHICS_NORMAL );
      dmd.drawString(  0 + (32 * x),  9 + (16 * y), "H:", 2, GRAPHICS_NORMAL );
    }
  }

  dmd.selectFont(System5x7);
  for (byte x = 0; x < DISPLAYS_ACROSS; x++)
  {
    for (byte y = 0; y < DISPLAYS_DOWN; y++)
    {
      dmd.drawString(  11 + (32 * x),  0 + (16 * y), t, 3, GRAPHICS_NORMAL );
      dmd.drawString(  11 + (32 * x),  9 + (16 * y), h, 3, GRAPHICS_NORMAL );
    }
  }

  dmd.drawCircle( 24,  1,  1, GRAPHICS_NORMAL );

  dmd.selectFont(System5x7);
  for (byte x = 0; x < DISPLAYS_ACROSS; x++)
  {
    for (byte y = 0; y < DISPLAYS_DOWN; y++)
    {
      dmd.drawString(  27 + (32 * x),  0 + (16 * y), "C", 2, GRAPHICS_NORMAL );
      dmd.drawString(  27 + (32 * x),  9 + (16 * y), "%", 2, GRAPHICS_NORMAL );
    }
  }

  delay(5000);
}
///////////////////////////////////////////////////


void setup()
{
  setup1();
  setup2();
  setup3();
}

void loop()
{
  loop1();
  loop2();
  loop3();
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.