Clock on dot matix.. byte to char conversion?

I couldn't find a example of anyone putting a RTC clock read out on a Dot matrix that worked for me. But i am able to get each one working so i combined the code. but I'm getting a error.

dot_matrix_working.ino: In function 'void displayTime()':
dot_matrix_working:210: error: invalid conversion from 'byte {aka unsigned char}' to 'char*' [-fpermissive]
dot_matrix_working:151: error: initializing argument 1 of 'void printString(char*)' [-fpermissive]
invalid conversion from 'byte {aka unsigned char}' to 'char*' [-fpermissive]

I dont understand whats really going on, I know the time is in one format byte? and the dot matrix will only display char?

dot_matrix_working.ino (8.45 KB)

You are not using a char. You are using a char array. Which element of the array do you want to convert the byte to?

readDS3232time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,

I want to display the time

as a test i used


but when it got to

void printString(char* s)
  int col = 0;
  while (*s != 0)
    if (*s < 32) continue;
    char c = *s - 32;
    memcpy_P(buffer, CH + 7*c, 7);
    m.writeSprite(col, 0, buffer);
    m.setColumn(col + buffer[0], 0);
    col += buffer[0] + 1;

it didn't know what to do with it is what it seems?

I think that what you want to do is convert numbers to a string.

There is a function called sprintf that is good for that.
More info here:
Please look at the attachment, which is what I have done with your program.
I have marked the parts I have changed with my username (odometer).
Please try it out and see if it does what you want it to do.
If it works, please study it and learn from it.
If it doesn't work, please tell me what went wrong so I can learn from it.

dot_matrix_working-1a.ino (8.63 KB)

the matrix is showing 45:165:85 and doesn't change no matter what i set the time to. I'll play around with it and see where these numbers are coming from and report back

I wonder if it's a hardware or a software problem.

I made some more changes to the displayTime() function.
What happens if you try it like this? What numbers appear?

void displayTime()
 byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  // odometer wants to see if this changes anything
  second = 59; // a valid time, but probably not the correct time
  minute = 4;
  hour = 12;
  dayOfWeek = 3;
  dayOfMonth = 1; // not today's date, but still a valid date
  month = 7;
  year = 15;  
  // retrieve data from DS3232
  readDS3232time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
  // odometer says to put the time in a string, like this:
  sprintf(timebuf, "%02d:%02d:%02d", hour, minute, second); 
  // odometer says to take that string and send it out, thus:

It reads out the same number.

Originally if i write printString(" test 12:45");
it prints it correctly and that is string?

Are you sure that your RTC is indeed working?

First up, like its been said already, printString( char * ) takes a string not a single byte.

I would first check your dot matrix by sending it a constant string:

printString( "10:15" );

If that works (and I think it will), I would next start printing out to serial your hour, min, second from the RTC:

byte time_components[7];
readDS3232time(&time_components[0], &time_components[1], &time_components[2], &time_components[3], &time_components[4], &time_components[5], &time_components[6]);

for( int i=0; i<7; i++ )
	Serial.Print( time_components[i] );
	Serial.Print( ":" );
Serial.Print( "\n" );

Make sure those values are correct.

:blush: very strange...

yes if i write something like printString(" test 12:45"); it appears as it should.

and if use the SetSerial.ino it appears to set the time correctly and I'm able to watch from serial Monitor the time changing. After odometer doubted the hardware I investigated if there's a issue and lo and behold on a MEGA the i2c pins are not A4 and A5

Everything's working beautifully.

Thanks guys :smiley: