Blinking 7 segments in arduino clock

I'm trying to make a clock using a 4-digits 7-segments display, an Arduino Leonardo and a DS3231 RTC. I got already the code for making the hour in a char array, but I'm having a hard time trying to display it correctly to the 7segs. When the arduino sends the hour to the displays, they only flashes it for an instant and then they turn of waiting for the next second to display the hour again and so on. I had the same issue using the code but adapted to use with a LCD, but I managed to fix it with just a delay. I tried the same with the 7segs but nothing happened. This is my code so far:

#include <DS3232RTC.h>        //http://github.com/JChristensen/DS3232RTC
#include <Streaming.h>        //http://arduiniana.org/libraries/streaming/
#include <Time.h>             //http://playground.arduino.cc/Code/Time
#include <Wire.h>             //http://arduino.cc/en/Reference/Wire
#include <SevSeg.h>           //https://github.com/sparkfun/SevSeg

SevSeg reloj7s;
char horaC[3], minC[3], horaDisp[5];

void setup(void)
{
Serial.begin(115200);

//setSyncProvider() causes the Time library to synchronize with the
//external RTC by calling RTC.get() every five minutes by default.
setSyncProvider(RTC.get);
Serial << F("RTC Sync");
if (timeStatus() != timeSet) Serial << F(" FAIL!");
Serial << endl;
int displayType = COMMON_ANODE;

int digit1 = A0; //Pin 12 on my 4 digit display
int digit2 = A1; //Pin 9 on my 4 digit display
int digit3 = 4; //Pin 8 on my 4 digit display
int digit4 = 5; //Pin 6 on my 4 digit display

//Declare what pins are connected to the segments
int segA = 6; //Pin 11 on my 4 digit display
int segB = 7; //Pin 7 on my 4 digit display
int segC = 8; //Pin 4 on my 4 digit display
int segD = 9; //Pin 2 on my 4 digit display
int segE = 10; //Pin 1 on my 4 digit display
int segF = 11; //Pin 10 on my 4 digit display
int segG = 12; //Pin 5 on my 4 digit display
int segDP= 13; //Pin 3 on my 4 digit display

int numberOfDigits = 4; //Do you have a 1, 2 or 4 digit display?

reloj7s.Begin(displayType, numberOfDigits, digit1, digit2, digit3, digit4, segA, segB, segC, segD, segE, segF, segG, segDP);

reloj7s.SetBrightness(100);
}

void loop(void)
{
static time_t tLast;
time_t t;
tmElements_t tm;

t = now();
if (t != tLast) {
    tLast = t;
    printDateTime(t);       
}
}

//print date and time to Serial
void printDateTime(time_t t)
{
printDate(t);
printTime(t); 
}

//I think the error may be here
//print time to 7S
void printTime(time_t t) {
 if(hour(t)<10){
  sprintf(horaC,"%d",hour(t));
  horaDisp[0]='0';
  horaDisp[1]=horaC[0];
  }
  else{
   sprintf(horaC,"%d",hour(t));
   horaDisp[0]=horaC[0];
   horaDisp[1]=horaC[1];
   }
 if(minute(t)<10){
  sprintf(minC,"%d",minute(t));
  horaDisp[2]='0';
  horaDisp[3]=minC[0];
  }
  else{
   sprintf(minC,"%d",minute(t));
   horaDisp[2]=minC[0];
   horaDisp[3]=minC[1];
   }
reloj7s.DisplayString(horaDisp,2);      //This is the function that sends the hour charArray to the 7Segs.
Serial.println(horaDisp);
}

//Ignore from this line
//print date to 7S 
void printDate(time_t t)
{
printI00(day(t), 0);
Serial << monthShortStr(month(t)) << _DEC(year(t));
}

//Print an integer in "00" format (with leading zero),
//followed by a delimiter character to Serial.
//Input value assumed to be between 0 and 99.
void printI00(int val, char delim)
{
if (val < 10) Serial << '0';
Serial << _DEC(val);
if (delim > 0) Serial << delim;
return;
}

I think the error might be in the printTime function while sending the reloj7s.DisplayString, but I'm not so sure. Can anybody help me how to fix this? Thanks.

I would write a simple sketch just to write one number such as 3 to one of the LEDs.

void writeToLed(int num, int whichLED)
{

...

}

Make sure the sketch works, then you can use that function in your original sketch.

I can't tell which version of SevSeg you're using. Whatever version it is, I suspect that it expects you to continuously refresh the display. When you call DisplayString once per second, it displays each digit for the time that you set in SetBrightness, and then shuts off, so that you see the digits flash once per second. I think that setting the brightness to 100 makes the display flash for 100 us. But, your version may differ.

Try adding the call to DisplayString as the last statement in loop(). That way, the code will test for an update to the time, and, whether it passes or fails, it will refrersh the display.

I think I know what it is. I did as ieee488 said and it displayed perfectly a 1 or 4 digits number using only the DisplayString function in the loop() function, but when I put a for loop in the code, it would blink as before. I think is what tmd3 said and I will put the DisplayString function in the loop().

tmd3, i'm using the revised version of sevseg by sparkfun

gardab:
... i'm using the revised version of sevseg by sparkfun

Got a link?

[Edit:]
\Oops; now I see the link, in a comment in your code.

I don't see anything in the readme that alerts you that DisplayString has to be called continuously. I do note, in the example sketch SevSeg_Counter, that it's called each time loop() executes. Looking into SevSeg.cpp, I see that DisplayString() displays each character of the display, waits for a period that's defined in setBrightness(), in turn, displays a special character if need be, and turns the display off. That fits with the notion that it must run periodically, and frequently, in order to generate a stable-looking display.