Someone Please Check My Code

Could someone please tell me the coding errors in this code? I have downloaded this code for my newly purchased DMD from Freetronics and don’t know how to program for DMD’s.

Master_Clock.ino (15.3 KB)

switch(hour)
  {
  case 1:
    dmd.drawString( 1,8, "01", 2, GRAPHICS_NORMAL );
    break;
  case 2:
    dmd.drawString( 1,8, "02", 2, GRAPHICS_NORMAL );
    break;
  case 3:
    dmd.drawString( 1,8, "03", 2, GRAPHICS_NORMAL );
    break;
  case 4:
    dmd.drawString( 1,8, "04", 2, GRAPHICS_NORMAL );
    break;
  case 5:
    dmd.drawString( 1,8, "05", 2, GRAPHICS_NORMAL );
    break;
  case 6:
    dmd.drawString( 1,8, "06", 2, GRAPHICS_NORMAL );
    break;
  case 7:
    dmd.drawString( 1,8, "07", 2, GRAPHICS_NORMAL );
    break;
  case 8:
    dmd.drawString( 1,8, "08", 2, GRAPHICS_NORMAL );
    break;
  case 9:
    dmd.drawString( 1,8, "09", 2, GRAPHICS_NORMAL );
    break;
  case 10:
    dmd.drawString( 1,8, "10", 2, GRAPHICS_NORMAL );
    break;
  case 11:
    dmd.drawString( 1,8, "11", 2, GRAPHICS_NORMAL );
    break;
  case 12:
    dmd.drawString( 1,8, "12", 2, GRAPHICS_NORMAL );
    break;
  case 13:
    dmd.drawString( 1,8, "13", 2, GRAPHICS_NORMAL );
    break;
  case 14:
    dmd.drawString( 1,8, "14", 2, GRAPHICS_NORMAL );
    break;
  case 15:
    dmd.drawString( 1,8, "15", 2, GRAPHICS_NORMAL );
    break;
  case 16:
    dmd.drawString( 1,8, "16", 2, GRAPHICS_NORMAL );
    break;
  case 17:
    dmd.drawString( 1,8, "17", 2, GRAPHICS_NORMAL );
    break;
  case 18:
    dmd.drawString( 1,8, "18", 2, GRAPHICS_NORMAL );
    break;
  case 19:
    dmd.drawString( 1,8, "19", 2, GRAPHICS_NORMAL );
    break;
  case 20:
    dmd.drawString( 1,8, "20", 2, GRAPHICS_NORMAL );
    break;
  case 21:
    dmd.drawString( 1,8, "21", 2, GRAPHICS_NORMAL );
    break;
  case 22:
    dmd.drawString( 1,8, "22", 2, GRAPHICS_NORMAL );
    break;
  case 23:
    dmd.drawString( 1,8, "23", 2, GRAPHICS_NORMAL );
    break;
  case 24:
    dmd.drawString( 1,8, "24", 2, GRAPHICS_NORMAL );
    break;

seems to me to be a very long-winded way of writing

char buffer [3];
sprintf (buffer, "%02d", hour);    
dmd.drawString( 1,8, buffer, 2, GRAPHICS_NORMAL );

I shudder to think what a drawYear function would have looked like!

Pete

The IDE still seems to have problems with the “#include <SPI.h>” part of the code.

What sort of problems ?

Master_Clock:15: error: expected identifier before numeric constant
Master_Clock:15: error: expected ',' or '...' before numeric constant
Master_Clock:46: error: expected identifier before numeric constant
Master_Clock:46: error: expected ',' or '...' before numeric constant
Master_Clock.ino: In function 'void setDateDs1307(byte, int)':
Master_Clock:57: error: 'minute' was not declared in this scope
Master_Clock:58: error: 'hour' was not declared in this scope
Master_Clock:61: error: 'month' was not declared in this scope
Master_Clock:62: error: 'year' was not declared in this scope

The errors have been resolved. I only had to redownload to file so I believe there could have been something wrong with the file. Thanks to everyone who tried to help