Proyecto reloj

Buenas tardes, soy Facundo y recien ando iniciandome en el mundo del arduino. Paso a comentarles, estoy realizando para el final de curso de mi secundaria (tecnica) un proyecto el cual es un reloj que muestra hora y minutos con 4 display 7 segmentos (2 para hora y 2 para minutos), para los cuales uso multiplexacion para ahorrar pines, y en una pantalla serie muestro datos del dht22(humedad y temperatura) + dia mes y año, los cuales salen de mi RTC(cabe aclarar que la hora que va en los displays tambien sale del dato de mi RTC). el segundero ira a otro pcb conformado por 4017's en cascada para asi ir prendiendo led por led por cada segundo.
Ahora, yo fui programando y probando por bloques, es decir la pantalla y el sensor por una lado, despues el RTC con pantalla y demas. a la hora de juntar el codigo este compila perfectamente pero aun asi no logro hacerlo funcionar en mi PCB(foto del esquematico →

les dejo el codigo que arme. espero que me puedan brindar una ayuda ya que no logro entender porque no funciona cada parte. debajo dejo las librerias adjuntas. Saludos

/* Control de 2 dislpays de siete segmentos CC con arduino

 
 ######################    Circuito    ######################


Control de 2 dislpays de siete segmentos Catodo Comun con arduino


 Pin 2  ->  segmento  a     del dispaly
 Pin 3  ->  segmento  b    del dispaly
 Pin 4  ->  segmento  c    del dispaly
 Pin 5  ->  segmento  d    del dispaly
 Pin 6  ->  segmento  e    del dispaly
 Pin 7  ->  segmento  f     del dispaly
 Pin 8  ->  segmento  g    del dispaly

 Pin 9  ->  Transistor del display de  Hdecenas     ( NPN )
 Pin 10 ->  Transistor del display de  Hunidades    ( NPN )
 Pin 11  -> Transistor del display de  Mdecenas     ( NPN )
 Pin 12 ->  Transistor del display de  Munidades    ( NPN )
 


 ######################################################

 */

#include "RTClib.h"
#include <Wire.h>
RTC_DS1307 RTC;
int segmento_a = 2; 
int segmento_b = 3; 
int segmento_c = 4; 
int segmento_d = 5; 
int segmento_e = 6; 
int segmento_f = 7; 
int segmento_g = 8; 

int transistor_hdecenas = 9; 
int transistor_hunidades = 10; 
int transistor_mdecenas = 11; 
int transistor_munidades = 12; 

int transistor_on = 5; 
int hunidad; 
int munidad; 
int hdecena; 
int mdecena;


void setup() {
  RTC.begin();
  Wire.begin();
  Serial.begin(9600);
  
  pinMode(segmento_a, OUTPUT);
  pinMode(segmento_b, OUTPUT);
  pinMode(segmento_c, OUTPUT);
  pinMode(segmento_d, OUTPUT);
  pinMode(segmento_e, OUTPUT);
  pinMode(segmento_f, OUTPUT);
  pinMode(segmento_g, OUTPUT);
  pinMode( transistor_hdecenas, OUTPUT);
  pinMode( transistor_hunidades, OUTPUT);
  pinMode( transistor_mdecenas, OUTPUT);
  pinMode( transistor_munidades, OUTPUT);
  


}

void loop() {

 
 Variableshora();

 displays7segmentos();

}







/* ##### Funcion tempozidador en la que unidades se incrementa cada segundo ##### */

void Variableshora() {
 DateTime now = RTC.now(); // Obtiene la fecha y hora del RTC
 
 hdecena=now.hour()/10;
 hunidad=now.hour()-(hdecena*10);
 mdecena=now.minute()/10;
 munidad=now.minute()-(hdecena*10);
 
} 





/* ##### Funcion que muestra los numeros en  2 displays  de 7 segmentos  ##### */

void displays7segmentos() {
 

/* Muestra hdecena */

digitalWrite(transistor_hdecenas, HIGH);
tabladisplay(hdecena);
delay(transistor_on);
digitalWrite(transistor_hdecenas, LOW);

/* Muestra hunidad */

digitalWrite(transistor_hunidades, HIGH);
tabladisplay(hunidad);
delay(transistor_on);
digitalWrite(transistor_hunidades, LOW);

/* Muestra mdecena */

digitalWrite(transistor_mdecenas, HIGH);
tabladisplay(mdecena);
delay(transistor_on);
digitalWrite(transistor_mdecenas, LOW);

/* Muestra munidad */

digitalWrite(transistor_munidades, HIGH);
tabladisplay(munidad);
delay(transistor_on);
digitalWrite(transistor_munidades, LOW);


}


/*##### Funcion que asocia el numero con su tabla de display de 7 segmentos Catodo Comun ##### */

void tabladisplay(int variablenumero) {

switch (variablenumero) {

case 0:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, HIGH);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, LOW);
break;

case 1:
digitalWrite(segmento_a, LOW);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, LOW);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, LOW);
digitalWrite(segmento_g, LOW);
break;

case 2:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, LOW);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, HIGH);
digitalWrite(segmento_f, LOW);
digitalWrite(segmento_g, HIGH);
break;

case 3:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, LOW);
digitalWrite(segmento_g, HIGH);
break;

case 4:
digitalWrite(segmento_a, LOW);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, LOW);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, HIGH);
break;

case 5:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, LOW); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, HIGH);
break;

case 6:
digitalWrite(segmento_a, LOW);
digitalWrite(segmento_b, LOW); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, HIGH);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, HIGH);
break;

case 7:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, LOW);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, LOW);
digitalWrite(segmento_g, LOW);
break;

case 8:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, HIGH);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, HIGH);
break;


case 9:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, LOW);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, HIGH);
break;

}
return;

}

libraries.zip (27.5 KB)

Te pregunto, funciona el multiplexado porque yo veo una mala conexión!! (espero que postees debidamente la foto mas alla que usaste bien el tag del enlace. Lo conveniente sería que se viera el esquema).

Tienes un transitor NPN BC548 (no muy apropiado para este fin pero sigamos), conectado al ánodo de un DISPLAY LED Anodo común.
Cuando exites el segmento, enviaras un HIGH y luego de la caida de tensión de led dificilmente tengas una tensión VCE tal que se sature debidamente el BC548

La conexión apropiada debes ser asi, (olvida el transitor, te mostraré con un NPN).
Tienes que poner el Colector a 5V y el emisor drenando corriente al Anodo común del DISPLAY LED.
Con un HIGH conduce como ahora pero ahora lo hará con buena corriente.

Dime si eso resuelve el problema DISPLAY.

Buenas, te comento que estoy probando con otro codigo un poco mas fiable, de hecho lo comprobé en protoboard y funciono a la perfeccion, el problema ahora es que al llevarlo a mi circuito impreso, lo unico que me muestran los displays son "5's" todos, es decir 5 5 : 5 5. alguna idea? aclaro que estuve midiendo que las conexiones en el pcb sean correctas y por lo visto todo esta en orden. Estoy alimentando mi circuito impreso con los +5 y gnd del arduino ya que no tengo a mano una fuente con 7805/regulable, modifico el codigo en el post principal (el de arriba de todo)

Saludos

Sin código y sin esquema es difícil seguirte.

Como postee antes, el código lo corregí en el original, osea está en la primera publicación, el esquema sigue siendo el mismo, de todas formas lo vuelvo a agregar

/* Control de 2 dislpays de siete segmentos CC con arduino

 
 ######################    Circuito    ######################


Control de 2 dislpays de siete segmentos Catodo Comun con arduino


 Pin 2  ->  segmento  a     del dispaly
 Pin 3  ->  segmento  b    del dispaly
 Pin 4  ->  segmento  c    del dispaly
 Pin 5  ->  segmento  d    del dispaly
 Pin 6  ->  segmento  e    del dispaly
 Pin 7  ->  segmento  f     del dispaly
 Pin 8  ->  segmento  g    del dispaly

 Pin 9  ->  Transistor del display de  Hdecenas     ( NPN )
 Pin 10 ->  Transistor del display de  Hunidades    ( NPN )
 Pin 11  -> Transistor del display de  Mdecenas     ( NPN )
 Pin 12 ->  Transistor del display de  Munidades    ( NPN )
 


 ######################################################

 */

#include "RTClib.h"
#include <Wire.h>
RTC_DS1307 RTC;
int segmento_a = 2; 
int segmento_b = 3; 
int segmento_c = 4; 
int segmento_d = 5; 
int segmento_e = 6; 
int segmento_f = 7; 
int segmento_g = 8; 

int transistor_hdecenas = 9; 
int transistor_hunidades = 10; 
int transistor_mdecenas = 11; 
int transistor_munidades = 12; 

int transistor_on = 5; 
int hunidad; 
int munidad; 
int hdecena; 
int mdecena;


void setup() {
  RTC.begin();
  Wire.begin();
  Serial.begin(9600);
  
  pinMode(segmento_a, OUTPUT);
  pinMode(segmento_b, OUTPUT);
  pinMode(segmento_c, OUTPUT);
  pinMode(segmento_d, OUTPUT);
  pinMode(segmento_e, OUTPUT);
  pinMode(segmento_f, OUTPUT);
  pinMode(segmento_g, OUTPUT);
  pinMode( transistor_hdecenas, OUTPUT);
  pinMode( transistor_hunidades, OUTPUT);
  pinMode( transistor_mdecenas, OUTPUT);
  pinMode( transistor_munidades, OUTPUT);
  


}

void loop() {

 
 Variableshora();

 displays7segmentos();

}







/* ##### Funcion tempozidador en la que unidades se incrementa cada segundo ##### */

void Variableshora() {
 DateTime now = RTC.now(); // Obtiene la fecha y hora del RTC
 
 hdecena=now.hour()/10;
 hunidad=now.hour()-(hdecena*10);
 mdecena=now.minute()/10;
 munidad=now.minute()-(hdecena*10);
 
} 





/* ##### Funcion que muestra los numeros en  2 displays  de 7 segmentos  ##### */

void displays7segmentos() {
 

/* Muestra hdecena */

digitalWrite(transistor_hdecenas, HIGH);
tabladisplay(hdecena);
delay(transistor_on);
digitalWrite(transistor_hdecenas, LOW);

/* Muestra hunidad */

digitalWrite(transistor_hunidades, HIGH);
tabladisplay(hunidad);
delay(transistor_on);
digitalWrite(transistor_hunidades, LOW);

/* Muestra mdecena */

digitalWrite(transistor_mdecenas, HIGH);
tabladisplay(mdecena);
delay(transistor_on);
digitalWrite(transistor_mdecenas, LOW);

/* Muestra munidad */

digitalWrite(transistor_munidades, HIGH);
tabladisplay(munidad);
delay(transistor_on);
digitalWrite(transistor_munidades, LOW);


}


/*##### Funcion que asocia el numero con su tabla de display de 7 segmentos Catodo Comun ##### */

void tabladisplay(int variablenumero) {

switch (variablenumero) {

case 0:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, HIGH);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, LOW);
break;

case 1:
digitalWrite(segmento_a, LOW);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, LOW);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, LOW);
digitalWrite(segmento_g, LOW);
break;

case 2:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, LOW);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, HIGH);
digitalWrite(segmento_f, LOW);
digitalWrite(segmento_g, HIGH);
break;

case 3:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, LOW);
digitalWrite(segmento_g, HIGH);
break;

case 4:
digitalWrite(segmento_a, LOW);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, LOW);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, HIGH);
break;

case 5:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, LOW); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, HIGH);
break;

case 6:
digitalWrite(segmento_a, LOW);
digitalWrite(segmento_b, LOW); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, HIGH);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, HIGH);
break;

case 7:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, LOW);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, LOW);
digitalWrite(segmento_g, LOW);
break;

case 8:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, HIGH);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, HIGH);
break;


case 9:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, LOW);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, HIGH);
break;

}
return;

}

Perdona a veces respondo tantas cosas que olvido lo anterior. Estaba respondido y cierto que lo habías editado luego de mi pedido.

Cómo es que en el protoboard te funcione y en el pcb no?
Revisaste cada conexión?

Para empezar he encontrado un leve error en rutina Variableshora() pero
me entusiasme y lo modifiqué un poco.

 /* Control de 2 dislpays de siete segmentos CC con arduino
 
 ######################    Circuito    ######################


Control de 2 dislpays de siete segmentos Catodo Comun con arduino


 Pin 2  ->  segmento  a     del dispaly
 Pin 3  ->  segmento  b    del dispaly
 Pin 4  ->  segmento  c    del dispaly
 Pin 5  ->  segmento  d    del dispaly
 Pin 6  ->  segmento  e    del dispaly
 Pin 7  ->  segmento  f     del dispaly
 Pin 8  ->  segmento  g    del dispaly

 Pin 9  ->  Transistor del display de  Hdecenas     ( NPN )
 Pin 10 ->  Transistor del display de  Hunidades    ( NPN )
 Pin 11  -> Transistor del display de  Mdecenas     ( NPN )
 Pin 12 ->  Transistor del display de  Munidades    ( NPN )

 ###################################################### */
#include <Wire.h>
#include "RTClib.h"
//#include <RTC_DS1307.h>

RTC_DS1307 rtc;

const byte segmento_a            = 2; 
const byte segmento_b            = 3; 
const byte segmento_c            = 4; 
const byte segmento_d            = 5; 
const byte segmento_e            = 6; 
const byte segmento_f            = 7; 
const byte segmento_g            = 8;
const byte segmento[7] = {2, 3, 4, 5, 6, 7, 8}; 

const byte transistor_hdecenas   = 9; 
const byte transistor_hunidades  = 10; 
const byte transistor_mdecenas   = 11; 
const byte transistor_munidades  = 12; 
const byte transistor[4] = {9, 10, 11, 12};

byte Digit[10][8] =
   { 
     { 1,1,1,1,1,1,0,0 },    // 0
     { 0,1,1,0,0,0,0,0 },    // 1
     { 1,1,0,1,1,0,1,0 },    // 2
     { 1,1,1,1,0,0,1,0 },    // 3
     { 0,1,1,0,0,1,1,0 },    // 4
     { 1,0,1,1,0,1,1,0 },    // 5
     { 1,0,1,1,1,1,1,0 },    // 6
     { 1,1,1,0,0,0,0,0 },    // 7
     { 1,1,1,1,1,1,1,0 },    // 8
     { 1,1,1,0,0,1,1,0 }     // 9
   };


  // con esta codificación los leds encienden correctamente
byte transistor_on = 5; 
byte hunidad; 
byte munidad; 
byte hdecena; 
byte mdecena;

void setup() {
  
  Serial.begin(9600);
  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__)));
    // 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));
  }
  
  for (byte i=0; i<7; i++) {
        pinMode(segmento[i], OUTPUT);    
  }
  for (byte i=0; i<4; i++) {
        pinMode(transistor[i], OUTPUT);    
  }
}

void loop() {

  Variableshora() ;  
}

void CalculaDigitos( int Num) {
  int Digit0 = Num %10 ;
  int Digit1 = (Num % 100) / 10 ;
  int Digit2 = (Num % 1000) / 100 ;
  int Digit3 = Num  / 1000 ;

  Display(3 , Digit3);
  Display(2 , Digit2);
  Display(1 , Digit1);
  Display(0 , Digit0);
}

/* ##### Funcion tempozidador en la que unidades se incrementa cada segundo ##### */

void Variableshora() {
  static byte ant;
  DateTime now = rtc.now(); // Obtiene la fecha y hora del RTC

  hdecena = now.hour()/10;
  hunidad = now.hour()%10;
  mdecena = now.minute()/10;
  munidad = now.minute()%10;
  
  if (munidad != ant) {
      char buffer[10];
      sprintf(buffer, "%d%d:%d%d", hdecena, hunidad, mdecena, munidad);
      Serial.println(buffer);
  }
  ant = munidad;
  Display(0, hdecena);
  Display(1, hunidad);
  Display(2, mdecena);
  Display(3, munidad); 
} 

void Display(int pos, int N) {  
       digitalWrite(transistor_hdecenas ,LOW);        // Apaga todos los digitos
       digitalWrite(transistor_hunidades,LOW);
       digitalWrite(transistor_mdecenas ,LOW);
       digitalWrite(transistor_munidades,LOW);
 
      for (int i= 0 ; i<8 ; i++)    // Esto no cambia de la session anterior
            digitalWrite(i+2 , Digit[N][i]) ;

      digitalWrite(transistor[pos], HIGH);      // Enciende el digito pos
  }

Prueba a ver como se comporta.
A mi no me funcionaba bien tu librería por eso agregué eso en el setup.
El resto es solo para hacerlo mas veloz.
Tal vez debas agregar algo de retarno para que se vean los dígitos. Te lo dejo a ti.

Hola de nuevo, te comento que logre solucionar el problema con la placa(mi propio circuito impreso). se me presenta un problema la verdad que considero raro. es que ahora el reloj hace algo extraño. no entiendo si es problema del 1307 RTC o de mi codigo quiza mal optimizado.
dejo el video del problema que subi yo mismo a youtube: Video de youtube

mi codigo actual:

/* Control de 2 dislpays de siete segmentos CC con arduino

 
 ######################    Circuito    ######################



Control de 2 dislpays de siete segmentos Catodo Comun con arduino


 Pin 2  ->  segmento  a     del dispaly
 Pin 3  ->  segmento  b    del dispaly
 Pin 4  ->  segmento  c    del dispaly
 Pin 5  ->  segmento  d    del dispaly
 Pin 6  ->  segmento  e    del dispaly
 Pin 7  ->  segmento  f     del dispaly
 Pin 8  ->  segmento  g    del dispaly

 Pin 9  ->  Transistor del display de  Hdecenas     ( NPN )
 Pin 10 ->  Transistor del display de  Hunidades    ( NPN )
 Pin 11  -> Transistor del display de  Mdecenas     ( NPN )
 Pin 12 ->  Transistor del display de  Munidades    ( NPN )
 


 ######################################################

 */
#include <LiquidCrystal_I2C.h>
#include "RTClib.h"
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
RTC_DS1307 RTC;
int segmento_a = 2; 
int segmento_b = 3; 
int segmento_c = 4; 
int segmento_d = 5; 
int segmento_e = 6; 
int segmento_f = 7; 
int segmento_g = 8; 

int transistor_hdecenas = 9; 
int transistor_hunidades = 10; 
int transistor_mdecenas = 11; 
int transistor_munidades = 12; 

long transistor_on = 500; 
int hunidad; 
int munidad; 
int hdecena; 
int mdecena;


void setup() {
  lcd.begin();
  lcd.backlight();
  RTC.begin();
  Wire.begin();
  Serial.begin(9600);
  
  pinMode(segmento_a, OUTPUT);
  pinMode(segmento_b, OUTPUT);
  pinMode(segmento_c, OUTPUT);
  pinMode(segmento_d, OUTPUT);
  pinMode(segmento_e, OUTPUT);
  pinMode(segmento_f, OUTPUT);
  pinMode(segmento_g, OUTPUT);
  pinMode( transistor_hdecenas, OUTPUT);
  pinMode( transistor_hunidades, OUTPUT);
  pinMode( transistor_mdecenas, OUTPUT);
  pinMode( transistor_munidades, OUTPUT);
  


}

void loop() {

 
 Variableshora();

 displays7segmentos();
 
 displaylcd();

}







/* ##### Funcion tempozidador en la que unidades se incrementa cada segundo ##### */

void Variableshora() {
 DateTime now = RTC.now(); // Obtiene la fecha y hora del RTC
 
 hdecena=now.minute()/10;
 hunidad=now.minute()-(hdecena*10);
 mdecena=now.second()/10;
 munidad=now.second()-(hdecena*10);
 
} 





/* ##### Funcion que muestra los numeros en  2 displays  de 7 segmentos  ##### */

void displays7segmentos() {
 

/* Muestra hdecena */

digitalWrite(transistor_hdecenas, HIGH);
tabladisplay(hdecena);
delayMicroseconds(transistor_on);
digitalWrite(transistor_hdecenas, LOW);

/* Muestra hunidad */

digitalWrite(transistor_hunidades, HIGH);
tabladisplay(hunidad);
delayMicroseconds(transistor_on);
digitalWrite(transistor_hunidades, LOW);

/* Muestra mdecena */

digitalWrite(transistor_mdecenas, HIGH);
tabladisplay(mdecena);
delayMicroseconds(transistor_on);
digitalWrite(transistor_mdecenas, LOW);

/* Muestra munidad */

digitalWrite(transistor_munidades, HIGH);
tabladisplay(munidad);
delayMicroseconds(transistor_on);
digitalWrite(transistor_munidades, LOW);


}






/*##### Funcion que controla la pantalla lcd, muestra temperatura, humedad y fecha #####*/

void displaylcd(){
  
 DateTime now = RTC.now(); 
 lcd.setCursor(0,0);
 lcd.print("Temperatura");             
 lcd.setCursor(0,1);
 lcd.print("Humedad");
 lcd.setCursor(0,2);
 lcd.print(now.day());
 lcd.print("/");
 lcd.print(now.month());
 lcd.print("/");
 lcd.print(now.year());
 lcd.setCursor(0,3);
 lcd.print("Temperatura");
  
 }




/*##### Funcion que asocia el numero con su tabla de display de 7 segmentos Catodo Comun ##### */

void tabladisplay(int variablenumero) {

switch (variablenumero) {

case 0:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, HIGH);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, LOW);
break;

case 1:
digitalWrite(segmento_a, LOW);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, LOW);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, LOW);
digitalWrite(segmento_g, LOW);
break;

case 2:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, LOW);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, HIGH);
digitalWrite(segmento_f, LOW);
digitalWrite(segmento_g, HIGH);
break;

case 3:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, LOW);
digitalWrite(segmento_g, HIGH);
break;

case 4:
digitalWrite(segmento_a, LOW);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, LOW);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, HIGH);
break;

case 5:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, LOW); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, HIGH);
break;

case 6:
digitalWrite(segmento_a, LOW);
digitalWrite(segmento_b, LOW); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, HIGH);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, HIGH);
break;

case 7:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, LOW);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, LOW);
digitalWrite(segmento_g, LOW);
break;

case 8:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, HIGH);
digitalWrite(segmento_e, HIGH);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, HIGH);
break;


case 9:
digitalWrite(segmento_a, HIGH);
digitalWrite(segmento_b, HIGH); 
digitalWrite(segmento_c, HIGH);
digitalWrite(segmento_d, LOW);
digitalWrite(segmento_e, LOW);
digitalWrite(segmento_f, HIGH);
digitalWrite(segmento_g, HIGH);
break;

}
return;

}

las librerias son las misma que subi al princpio.
Saludos y gracias por su ayuda

y vuelves a repetir el mismo error que ya te señalé y corregí!!

 hdecena=now.minute()/10;
 hunidad=now.minute()-(hdecena*10);
 mdecena=now.second()/10;
 munidad=now.second()-(hdecena*10); // <== ERROR debe decir mdecena!!

Por cierto, gracias por no probar mi código!!

Hola de nuevo Surbyte y gracias de nuevo como siempre. habia olvidado probar tu codigo!!!!!!!!. desde funciona perfecto. el tema es que no logro entender algunas partes. por eso se me dificulta su manipulacion. Note un problema y es que por lo que veo a la hora de probarlo la intensidad de cada display 7 segmentos cae progresivamente. por lo que entiendo es problema de multiplexacion, osea habria que aumentar un poco el delay entre el muestreo de cada variable en cada display, ¿se entiende?. lo haria por mi cuenta pero com ote comente no logro entender como realizaste el codeo gracais a mi amateurismo.

en tanto te comento que agregue al final una nueva funcion, la cual es el uso del display lcd. y me dice que ciertas variables no estan declaradas aqui, no sabria como llamarlas a esa funcion. Saludos

el codigo actual:

/* Control de 2 dislpays de siete segmentos CC con arduino
 
 ######################    Circuito    ######################


Control de 2 dislpays de siete segmentos Catodo Comun con arduino


 Pin 2  ->  segmento  a     del dispaly
 Pin 3  ->  segmento  b    del dispaly
 Pin 4  ->  segmento  c    del dispaly
 Pin 5  ->  segmento  d    del dispaly
 Pin 6  ->  segmento  e    del dispaly
 Pin 7  ->  segmento  f     del dispaly
 Pin 8  ->  segmento  g    del dispaly

 Pin 9  ->  Transistor del display de  Hdecenas     ( NPN )
 Pin 10 ->  Transistor del display de  Hunidades    ( NPN )
 Pin 11  -> Transistor del display de  Mdecenas     ( NPN )
 Pin 12 ->  Transistor del display de  Munidades    ( NPN )

 ###################################################### */
#include <DHT.h>
#define DHTPIN 1
#define DHTTYPE DHT22 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
#include <Wire.h>
#include "RTClib.h"
//#include <RTC_DS1307.h>

RTC_DS1307 rtc;

const byte segmento_a            = 2; 
const byte segmento_b            = 3; 
const byte segmento_c            = 4; 
const byte segmento_d            = 5; 
const byte segmento_e            = 6; 
const byte segmento_f            = 7; 
const byte segmento_g            = 8;
const byte segmento[7] = {2, 3, 4, 5, 6, 7, 8}; 

const byte transistor_hdecenas   = 9; 
const byte transistor_hunidades  = 10; 
const byte transistor_mdecenas   = 11; 
const byte transistor_munidades  = 12; 
const byte transistor[4] = {9, 10, 11, 12};

byte Digit[10][8] =
   { 
     { 1,1,1,1,1,1,0,0 },    // 0
     { 0,1,1,0,0,0,0,0 },    // 1
     { 1,1,0,1,1,0,1,0 },    // 2
     { 1,1,1,1,0,0,1,0 },    // 3
     { 0,1,1,0,0,1,1,0 },    // 4
     { 1,0,1,1,0,1,1,0 },    // 5
     { 1,0,1,1,1,1,1,0 },    // 6
     { 1,1,1,0,0,0,0,0 },    // 7
     { 1,1,1,1,1,1,1,0 },    // 8
     { 1,1,1,0,0,1,1,0 }     // 9
   };


  // con esta codificación los leds encienden correctamente
byte transistor_on = 5; 
byte hunidad; 
byte munidad; 
byte hdecena; 
byte mdecena;

void setup() {
  lcd.begin();
  lcd.backlight();
  dht.begin();
  
  Serial.begin(9600);
  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__)));
    // 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));
  }
  
  for (byte i=0; i<7; i++) {
        pinMode(segmento[i], OUTPUT);    
  }
  for (byte i=0; i<4; i++) {
        pinMode(transistor[i], OUTPUT);    
  }
}

void loop() {

  Variableshora() ;  
  display20x4();
  
}

void CalculaDigitos( int Num) {
  int Digit0 = Num %10 ;
  int Digit1 = (Num % 100) / 10 ;
  int Digit2 = (Num % 1000) / 100 ;
  int Digit3 = Num  / 1000 ;

  Display(3 , Digit3);
  Display(2 , Digit2);
  Display(1 , Digit1);
  Display(0 , Digit0);
  

}

/* ##### Funcion tempozidador en la que unidades se incrementa cada segundo ##### */

void Variableshora() {
  static byte ant;
  DateTime now = rtc.now(); // Obtiene la fecha y hora del RTC

  hdecena = now.hour()/10;
  hunidad = now.hour()%10;
  mdecena = now.second()/10;
  munidad = now.second()%10;
  
  if (munidad != ant) {
      char buffer[10];
      sprintf(buffer, "%d%d:%d%d", hdecena, hunidad, mdecena, munidad);
      Serial.println(buffer);
  }
  ant = munidad;
  Display(0, hdecena);
  Display(1, hunidad);
  Display(2, mdecena);
  Display(3, munidad); 
} 

void Display(int pos, int N) {  
       digitalWrite(transistor_hdecenas ,LOW);        // Apaga todos los digitos
       digitalWrite(transistor_hunidades,LOW);
       digitalWrite(transistor_mdecenas ,LOW);
       digitalWrite(transistor_munidades,LOW);
 
      for (int i= 0 ; i<8 ; i++)    // Esto no cambia de la session anterior
            digitalWrite(i+2 , Digit[N][i]) ;

      digitalWrite(transistor[pos], HIGH);      // Enciende el digito pos
  }
  
  
void display20x4(){
 int h = dht.readHumidity();
 int t = dht.readTemperature();
  
 lcd.setCursor(0,0);
 lcd.print("Temperatura "); 
 lcd.print(t); 
 lcd.setCursor(0,1);
 lcd.print("Humedad ");
 lcd.print(h);
 lcd.setCursor(0,2);
 lcd.print(now.day());
 lcd.print("/");
 lcd.print(now.month());
 lcd.print("/");
 lcd.print(now.year());
 lcd.setCursor(0,3);
 lcd.print("Temperatura");
  
 }

Analiza esta librería SevenSegment Library. Es una librería que hace un verdadero multiplexado usando el timer del Arduino.

Y en cuanto a llevar las variables que al compilar me dicen que no fueron declaradas como podria arreglarlo?

No hables en el aire, se preciso.
Yo respondo muchos post y vengo y leo

Y en cuanto a llevar las variables que al compilar me dicen que no fueron declaradas como podria arreglarlo?

Cuales variables

a esa seccion me refiero con que "dht" y "now" no estan declaradas:

void display20x4(){
 int h = dht.readHumidity();
 int t = dht.readTemperature();
  
 lcd.setCursor(0,0);
 lcd.print("Temperatura "); 
 lcd.print(t); 
 lcd.setCursor(0,1);
 lcd.print("Humedad ");
 lcd.print(h);
 lcd.setCursor(0,2);
 lcd.print(now.day());
 lcd.print("/");
 lcd.print(now.month());
 lcd.print("/");
 lcd.print(now.year());
 lcd.setCursor(0,3);
 lcd.print("Temperatura");
  
 }

Creo que los valores t y h deben ser float.

cambie el tipo de variable y el error sigue siendo el mismo.

"a.ino: In function 'void setup()':
a.ino:75:3: error: 'dht' was not declared in this scope
a.ino: In function 'void display20x4()':
a.ino:158:12: error: 'dht' was not declared in this scope
a.ino:168:12: error: 'now' was not declared in this scope
Error de compilación"

A mi no me da error

[ Deviot 1.2.5 ] Borrar_0.ino
20:22:42 Compilando el proyecto | Procesando...
In file included from C:\users\ricardo\.platformio\lib\LiquidCrystal_ID136\LiquidCrystal_SR1W.cpp:36:0:
C:\users\ricardo\.platformio\lib\LiquidCrystal_ID136\LiquidCrystal_SR1W.h:157:1: warning: multi-line comment [-Wcomment]
//             |    |      0.1uf            |     \
^
20:23:02 ÉXITO pero con ADVERTENCIA(s) | Demoró 20.71s

resulto ser error de novato :confused: al final lo solucione investigando un poco.

en cuanto al multiplexado, Surbyte, no logro comprendenderlo para hacerlo por mi cuenta, ya que tu al haberme modificado el programa, com ote comente, hay ciertas sentencias que no las logro entender.
Desde mi simple lugar entiendo que segun tu codigo, lo pones en los displays 7seg aqui:

if (munidad != ant) {
      char buffer[10];
      sprintf(buffer, "%d%d:%d%d", hdecena, hunidad, mdecena, munidad);
      Serial.println(buffer);

pero no sabria como darle un delay minimo.

dejo el codigo actual.
Saludos y gracias como siempre!!!
(despues de tanta ayuda, apareceras como mi salvador en el informe final :slight_smile: )

/* Control de 2 dislpays de siete segmentos CC con arduino
 
 ######################    Circuito    ######################


Control de 2 dislpays de siete segmentos Catodo Comun con arduino


 Pin 2  ->  segmento  a     del dispaly
 Pin 3  ->  segmento  b    del dispaly
 Pin 4  ->  segmento  c    del dispaly
 Pin 5  ->  segmento  d    del dispaly
 Pin 6  ->  segmento  e    del dispaly
 Pin 7  ->  segmento  f     del dispaly
 Pin 8  ->  segmento  g    del dispaly

 Pin 9  ->  Transistor del display de  Hdecenas     ( NPN )
 Pin 10 ->  Transistor del display de  Hunidades    ( NPN )
 Pin 11  -> Transistor del display de  Mdecenas     ( NPN )
 Pin 12 ->  Transistor del display de  Munidades    ( NPN )

 ###################################################### */
#include <DHT.h>

#define DHTPIN 1
#define DHTTYPE DHT22 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
#include <Wire.h>
#include "RTClib.h"
DHT dht(DHTPIN, DHTTYPE);
RTC_DS1307 rtc;

const byte segmento_a            = 2; 
const byte segmento_b            = 3; 
const byte segmento_c            = 4; 
const byte segmento_d            = 5; 
const byte segmento_e            = 6; 
const byte segmento_f            = 7; 
const byte segmento_g            = 8;
const byte segmento[7] = {2, 3, 4, 5, 6, 7, 8}; 

const byte transistor_hdecenas   = 9; 
const byte transistor_hunidades  = 10; 
const byte transistor_mdecenas   = 11; 
const byte transistor_munidades  = 12; 
const byte transistor[4] = {9, 10, 11, 12};

byte Digit[10][8] =
   { 
     { 1,1,1,1,1,1,0,0 },    // 0
     { 0,1,1,0,0,0,0,0 },    // 1
     { 1,1,0,1,1,0,1,0 },    // 2
     { 1,1,1,1,0,0,1,0 },    // 3
     { 0,1,1,0,0,1,1,0 },    // 4
     { 1,0,1,1,0,1,1,0 },    // 5
     { 1,0,1,1,1,1,1,0 },    // 6
     { 1,1,1,0,0,0,0,0 },    // 7
     { 1,1,1,1,1,1,1,0 },    // 8
     { 1,1,1,0,0,1,1,0 }     // 9
   };


  // con esta codificación los leds encienden correctamente
byte transistor_on = 5; 
byte hunidad; 
byte munidad; 
byte hdecena; 
byte mdecena;

void setup() {
  lcd.begin();
  lcd.backlight();
  dht.begin();
  
  Serial.begin(9600);
  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__)));
    // 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));
  }
  
  for (byte i=0; i<7; i++) {
        pinMode(segmento[i], OUTPUT);    
  }
  for (byte i=0; i<4; i++) {
        pinMode(transistor[i], OUTPUT);    
  }
}

 void loop() {
  
  Variableshora();  
  display20x4();
  
  
}

void CalculaDigitos( int Num) {
  int Digit0 = Num %10 ;
  int Digit1 = (Num % 100) / 10 ;
  int Digit2 = (Num % 1000) / 100 ;
  int Digit3 = Num  / 1000 ;

  Display(3 , Digit3);
  Display(2 , Digit2);
  Display(1 , Digit1);
  Display(0 , Digit0);
  

}

/* ##### Funcion tempozidador en la que unidades se incrementa cada segundo ##### */

void Variableshora() {
  DateTime now = rtc.now(); // Obtiene la fecha y hora del RTC
  static byte ant;

  hdecena = now.hour()/10;
  hunidad = now.hour()%10;
  mdecena = now.second()/10;
  munidad = now.second()%10;
  
  if (munidad != ant) {
      char buffer[10];
      sprintf(buffer, "%d%d:%d%d", hdecena, hunidad, mdecena, munidad);
      Serial.println(buffer);
  }
  ant = munidad;
  Display(0, hdecena);
  Display(1, hunidad);
  Display(2, mdecena);
  Display(3, munidad); 
} 

void Display(int pos, int N) {  
       digitalWrite(transistor_hdecenas ,LOW);        // Apaga todos los digitos
       digitalWrite(transistor_hunidades,LOW);
       digitalWrite(transistor_mdecenas ,LOW);
       digitalWrite(transistor_munidades,LOW);
 
      for (int i= 0 ; i<8 ; i++)    // Esto no cambia de la session anterior
            digitalWrite(i+2 , Digit[N][i]) ;

      digitalWrite(transistor[pos], HIGH);      // Enciende el digito pos
  }
  
  
void display20x4(){
 DateTime now = rtc.now(); // Obtiene la fecha y hora del RTC
 int h = dht.readHumidity();
 int t = dht.readTemperature();
  
 lcd.setCursor(0,0);
 lcd.print("Temperatura "); 
 lcd.print(t); 
 lcd.setCursor(0,1);
 lcd.print("Humedad ");
 lcd.print(h);
 lcd.setCursor(0,2);
 lcd.print(now.day());
 lcd.print("/");
 lcd.print(now.month());
 lcd.print("/");
 lcd.print(now.year());
 lcd.setCursor(0,3);
 lcd.print("Temperatura");
  
 }

El problema es que esa parte de código solo te muestra un dato en el monitor Serie cuando

if (munidad != ant) {

o sea cuando cambia el segundo para no enviarte una seguidilla de datos similares.
y esto es el reemplazo de tus Serial.print individuales para hdecena, hunidad, mdecena, munidad, en un solo paso
Cada %d es un dato entero que sabemos que solo tiene 1 digito
Todo lo que esta entre comillas se va a almacenar en una cadena de char con el formato
"hh:mm" en la variable buffer, que imprimes con un simple comando.

sprintf(buffer, "%d%d:%d%d", hdecena, hunidad, mdecena, munidad);
      Serial.println(buffer);

O sea.. esas largas lineas de codigo poniendo etiquetas y luego la variable para monitorear en el puerto serie se reemplazan por este armado.
Busca en Google: Arduino sprintf o simplemente sprintf porque es un comando de C

Hola, termine resolviendo el problema A MEDIAS. al agregar el codigo para la pantalla lcd no puedo lograr que los displays se vean correctamente, es decir el primero funciona perfecto, el segundo, tercero y cuarto, titilan y se cortan medio segundo y despues siguen funcionando. Cambiando el tiempo de multiplexado lo unico que logro es cambiar la corriente de los displays, la cual va disminuyendo por cada uno, es decir la solucion no parece estar ahi.
En cambio si saco la sentencia en la que uso mi pantalla, esto funciona perfecto. no logro entender como hacerlo mejorar. sabrisa como optimizar mas el codigo quiza?. por mi cuenta no logro hacerlo

codigo actual:

/* Control de 2 dislpays de siete segmentos CC con arduino
 
 ######################    Circuito    ######################


Control de 2 dislpays de siete segmentos Catodo Comun con arduino


 Pin 2  ->  segmento  a     del dispaly
 Pin 3  ->  segmento  b    del dispaly
 Pin 4  ->  segmento  c    del dispaly
 Pin 5  ->  segmento  d    del dispaly
 Pin 6  ->  segmento  e    del dispaly
 Pin 7  ->  segmento  f     del dispaly
 Pin 8  ->  segmento  g    del dispaly

 Pin 9  ->  Transistor del display de  Hdecenas     ( NPN )
 Pin 10 ->  Transistor del display de  Hunidades    ( NPN )
 Pin 11  -> Transistor del display de  Mdecenas     ( NPN )
 Pin 12 ->  Transistor del display de  Munidades    ( NPN )

 ###################################################### */
#include <DHT.h>

#define DHTPIN 1
#define DHTTYPE DHT22 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
#include <Wire.h>
#include "RTClib.h"
DHT dht(DHTPIN, DHTTYPE);
RTC_DS1307 rtc;

const byte segmento_a            = 2; 
const byte segmento_b            = 3; 
const byte segmento_c            = 4; 
const byte segmento_d            = 5; 
const byte segmento_e            = 6; 
const byte segmento_f            = 7; 
const byte segmento_g            = 8;
const byte segmento[7] = {2, 3, 4, 5, 6, 7, 8}; 

const byte transistor_hdecenas   = 9; 
const byte transistor_hunidades  = 10; 
const byte transistor_mdecenas   = 11; 
const byte transistor_munidades  = 12; 
const byte transistor[4] = {9, 10, 11, 12};

byte Digit[10][8] =
   { 
     { 1,1,1,1,1,1,0,0 },    // 0
     { 0,1,1,0,0,0,0,0 },    // 1
     { 1,1,0,1,1,0,1,0 },    // 2
     { 1,1,1,1,0,0,1,0 },    // 3
     { 0,1,1,0,0,1,1,0 },    // 4
     { 1,0,1,1,0,1,1,0 },    // 5
     { 1,0,1,1,1,1,1,0 },    // 6
     { 1,1,1,0,0,0,0,0 },    // 7
     { 1,1,1,1,1,1,1,0 },    // 8
     { 1,1,1,0,0,1,1,0 }     // 9
   };


  // con esta codificación los leds encienden correctamente
byte transistor_on = 5; 
byte hunidad; 
byte munidad; 
byte hdecena; 
byte mdecena;

void setup() {
  lcd.begin();
  lcd.backlight();
  dht.begin();
  rtc.begin();
  
  for (byte i=0; i<7; i++) {
        pinMode(segmento[i], OUTPUT);    
  }
  for (byte i=0; i<4; i++) {
        pinMode(transistor[i], OUTPUT);    
  }
  
  
}

 void loop() {
  
  Variableshora();  
  display20x4();
  
  
}

void CalculaDigitos( int Num) {
  int Digit0 = Num %10 ;
  int Digit1 = (Num % 100) / 10 ;
  int Digit2 = (Num % 1000) / 100 ;
  int Digit3 = Num  / 1000 ;

  Display(3 , Digit3);
  Display(2 , Digit2);
  Display(1 , Digit1);
  Display(0 , Digit0);
  

}

/* ##### Funcion tempozidador en la que unidades se incrementa cada segundo ##### */

void Variableshora() {
  DateTime now = rtc.now(); // Obtiene la fecha y hora del RTC
  static byte ant;

  hdecena = now.hour()/10;
  hunidad = now.hour()%10;
  mdecena = now.minute()/10;
  munidad = now.minute()%10;
  
  if (munidad != ant) {
      char buffer[10];
      sprintf(buffer, "%d%d:%d%d", hdecena, hunidad, mdecena, munidad);
      Serial.println(buffer);
  }
  ant = munidad;
  Display(0, hdecena);
  delay(7);
  Display(1, hunidad);
  delay(7);
  Display(2, mdecena);
  delay(7);
  Display(3, munidad); 
  delay(7);
} 

void Display(int pos, int N) {  
       digitalWrite(transistor_hdecenas ,LOW);        // Apaga todos los digitos
       digitalWrite(transistor_hunidades,LOW);
       digitalWrite(transistor_mdecenas ,LOW);
       digitalWrite(transistor_munidades,LOW);
 
      for (int i= 0 ; i<8 ; i++)    // Esto no cambia de la session anterior
            digitalWrite(i+2 , Digit[N][i]) ;

      digitalWrite(transistor[pos], HIGH);      // Enciende el digito pos
  }
  
  
void display20x4(){
 DateTime now = rtc.now(); // Obtiene la fecha y hora del RTC
 int h = dht.readHumidity();
 int t = dht.readTemperature();
  
 lcd.setCursor(0,0);
 lcd.print("Temperatura "); 
 lcd.print(t); 
 lcd.setCursor(0,1);
 lcd.print("Humedad ");
 lcd.print(h);
 lcd.setCursor(0,2);
 lcd.print(now.day());
 lcd.print("/");
 lcd.print(now.month());
 lcd.print("/");
 lcd.print(now.year());
 lcd.setCursor(0,3);
 lcd.print("Temperatura");
  
 }

Saludos Facundo.

Prueba con el siguiente código

/* Control de 2 dislpays de siete segmentos CC con arduino
 
 ######################    Circuito    ######################


Control de 2 dislpays de siete segmentos Catodo Comun con arduino


 Pin 2  ->  segmento  a    del dispaly
 Pin 3  ->  segmento  b    del dispaly
 Pin 4  ->  segmento  c    del dispaly
 Pin 5  ->  segmento  d    del dispaly
 Pin 6  ->  segmento  e    del dispaly
 Pin 7  ->  segmento  f    del dispaly
 Pin 8  ->  segmento  g    del dispaly

 Pin 9  ->  Transistor del display de  Hdecenas     ( NPN )
 Pin 10 ->  Transistor del display de  Hunidades    ( NPN )
 Pin 11  -> Transistor del display de  Mdecenas     ( NPN )
 Pin 12 ->  Transistor del display de  Munidades    ( NPN )

 ###################################################### */

 
#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include "RTClib.h"

#define DHTPIN 1
#define DHTTYPE DHT22 

LiquidCrystal_I2C lcd(0x27, 20, 4);

DHT dht(DHTPIN, DHTTYPE);
RTC_DS1307 rtc;

const byte segmento_a            = 2; 
const byte segmento_b            = 3; 
const byte segmento_c            = 4; 
const byte segmento_d            = 5; 
const byte segmento_e            = 6; 
const byte segmento_f            = 7; 
const byte segmento_g            = 8;
const byte segmento[7] = {2, 3, 4, 5, 6, 7, 8}; 

const byte transistor_hdecenas   = 9; 
const byte transistor_hunidades  = 10; 
const byte transistor_mdecenas   = 11; 
const byte transistor_munidades  = 12; 
const byte transistor[4] = {9, 10, 11, 12};

byte Digit[10][8] =
   { 
     { 1,1,1,1,1,1,0,0 },    // 0
     { 0,1,1,0,0,0,0,0 },    // 1
     { 1,1,0,1,1,0,1,0 },    // 2
     { 1,1,1,1,0,0,1,0 },    // 3
     { 0,1,1,0,0,1,1,0 },    // 4
     { 1,0,1,1,0,1,1,0 },    // 5
     { 1,0,1,1,1,1,1,0 },    // 6
     { 1,1,1,0,0,0,0,0 },    // 7
     { 1,1,1,1,1,1,1,0 },    // 8
     { 1,1,1,0,0,1,1,0 }     // 9
   };


  // con esta codificación los leds encienden correctamente
byte transistor_on = 5; 
byte hunidad; 
byte munidad; 
byte hdecena; 
byte mdecena;

  // Variable auxiliar para obtener los segundos
byte rtcSeg = 0;


void setup() {
  
  lcd.begin();
  lcd.backlight();
  dht.begin();
  rtc.begin();
  
  for (byte i=0; i<7; i++) {
        pinMode(segmento[i], OUTPUT);    
  }
  for (byte i=0; i<4; i++) {
        pinMode(transistor[i], OUTPUT);    
  }
  
}

 void loop() {
  
  Variableshora();
  
  if( rtcSeg % 10 == 0 )
	display20x4();
  
}

/*
void CalculaDigitos( int Num ) {
  int Digit0 = Num %10 ;
  int Digit1 = (Num % 100) / 10 ;
  int Digit2 = (Num % 1000) / 100 ;
  int Digit3 = Num  / 1000 ;

  Display(3 , Digit3);
  Display(2 , Digit2);
  Display(1 , Digit1);
  Display(0 , Digit0);
}
*/

/* ##### Funcion tempozidador en la que unidades se incrementa cada segundo ##### */

void Variableshora() {
  DateTime now = rtc.now(); // Obtiene la fecha y hora del RTC
  static byte ant;

  hdecena = now.hour()/10;
  hunidad = now.hour()%10;
  mdecena = now.minute()/10;
  munidad = now.minute()%10;
  
  rtcSeg = now.second();
  
  if (munidad != ant) {
      char buffer[10];
      sprintf(buffer, "%d%d:%d%d", hdecena, hunidad, mdecena, munidad);
      Serial.println(buffer);
  }
  
  ant = munidad;
  Display(0, hdecena);
  delay(7);
  Display(1, hunidad);
  delay(7);
  Display(2, mdecena);
  delay(7);
  Display(3, munidad); 
  delay(7);
} 

void Display(int pos, int N) {
  
  digitalWrite(transistor_hdecenas , LOW);        // Apaga todos los digitos
  digitalWrite(transistor_hunidades, LOW);
  digitalWrite(transistor_mdecenas , LOW);
  digitalWrite(transistor_munidades, LOW);
  
  byte i=2;
  for (; i<8; i++)    // Esto no cambia de la session anterior
    { digitalWrite(i, Digit[N][i] ) ; }

  digitalWrite(transistor[pos], HIGH);      // Enciende el digito pos
  
}
  
  
void display20x4(){
	
  char buffer[21];
  
  DateTime now = rtc.now(); // Obtiene la fecha y hora del RTC
  int h = dht.readHumidity();
  int t = dht.readTemperature();
  
  lcd.setCursor(0,0);
  sprintf(buffer, "Temperatura %d", t);
  lcd.print(buffer);
  
  lcd.setCursor(0,1);
  sprintf(buffer, "Humedad %d", h);
  lcd.print(buffer);
  
  lcd.setCursor(0,2);
  sprintf( buffer, "%d/%d/%d", now.day(), now.month(), now.year() )
  lcd.print(buffer);

  lcd.setCursor(0,3);
  lcd.print("Temperatura");
  
 }

La razón de lo que se está visualizando en los displays reside en que el código tarda mucho tiempo en volver a refrescar (hacer el barrido) de los display. En el ciclo infitnito de su código, cuando se llama a la función "Variableshora()" si usted se fija bien, el último display que queda encendido es el número 3 ( Display(3, munidad) ), es decir, el display de las unidades de minuto, luego regresa al ciclo (loop) y llama a la función "display20x4()" en la cual su código está tomando mucho tiempo para imprimir la información en el LCD con todos los "lcd.print" que tiene para luego voler al 'loop' y hacer nuevamente el barrido, causando esto el efecto en el que "pareciese" que los demás segmentos se iluminan debilmente excepto el de las unidades de los minutos que es el que permanece más tiempo encendido.

En este código incluí una condición para que la información en el LCD se actualice cada 10 segundos, como veo que no se está mostrando segundos en la pantalla LCD, no hay inconveniente con esta tasa de actualización para el LCD, además la información allí presentada no se torna débil si no se le actualiza a una frecuencia más alta. Si la temperatura o humedad que se está midiendo no tienen cambios muy rápidos, se puede aumentar el intervalo de actualización a 15, 20, 30 o incluso 60 segundos, así no se preentará ese efecto de debilitamiento en la visualización en los display.

Vladimir Zúñiga