dmd stops refreshing after third image

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
Post Reply
jedihermit
Posts: 3
Joined: Fri Apr 17, 2015 2:04 pm

dmd stops refreshing after third image

Post by jedihermit » Wed Dec 07, 2016 6:26 pm

I'm working on a nerf target scoreboard with my DMD. I set a void for each score 1-10 and they display properly one at a time but if I run through 1-10 it usually hangs on the third display and starts garbage output. Is there a way to clear the buffer besides dmd.clearscreen(true)? I also can't change the font because is says arial isn't declared in the scope but I never declared SystemFont5x7 and it works. Thanks for any suggestions.

Code: Select all

#define relay 3 //relay trigger digital 3
#include "SPI.h"      
#include "DMD.h" 
#include "TimerOne.h"
#include "SystemFont5x7.h"
#include "Arial14.h"
#include "Arial_black_16.h"
#define DISPLAYS_ACROSS 1   
#define DISPLAYS_DOWN 1       
DMD dmd(DISPLAYS_ACROSS,DISPLAYS_DOWN);
int score = 0;




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

void setup()
{

   // Setup Serial which is useful for debugging
    // Use the Serial Monitor to view printed messages
    Serial.begin(9600);
    Serial.println("start");

      //score
   //int score = 0;
      
    //sensors
pinMode (relay, OUTPUT);

  //display
 
  Timer1.initialize( 5000 );           
  Timer1.attachInterrupt( ScanDMD );  
  dmd.clearScreen( true ); 
  zero();           
}




  //zero
  void zero()
{
 
   // display some text
   dmd.clearScreen( true );
   dmd.selectFont(SystemFont5x7);
   for (byte x=0;x<DISPLAYS_ACROSS;x++) {
     for (byte y=0;y<DISPLAYS_DOWN;y++) {
      dmd.drawString(  2+(32*x),  1+(16*y), "score", 5, GRAPHICS_NORMAL );
      dmd.drawString(  14+(32*x),  9+(16*y), "0", 1, GRAPHICS_NORMAL );
     }
   }
   delay( 2000 );
  }

 

//one
  void one()
{
 
   // display some text
   dmd.clearScreen( true );
   dmd.selectFont(SystemFont5x7);
   for (byte x=0;x<DISPLAYS_ACROSS;x++) {
     for (byte y=0;y<DISPLAYS_DOWN;y++) {
      dmd.drawString(  2+(32*x),  1+(16*y), "score", 5, GRAPHICS_NORMAL );
      dmd.drawString(  14+(32*x),  9+(16*y), "1", 1, GRAPHICS_NORMAL );
     }
   }
   delay( 2000 );
  }

//two
  void two()
{
 
   // display some text
   dmd.clearScreen( true );
   dmd.selectFont(SystemFont5x7);
   for (byte x=0;x<DISPLAYS_ACROSS;x++) {
     for (byte y=0;y<DISPLAYS_DOWN;y++) {
      dmd.drawString(  2+(32*x),  1+(16*y), "score", 5, GRAPHICS_NORMAL );
      dmd.drawString(  14+(32*x),  9+(16*y), "2", 1, GRAPHICS_NORMAL );
     }
   }
     delay( 2000 );
  }

//three
  void three()
{
 
   // display some text
   dmd.clearScreen( true );
   dmd.selectFont(SystemFont5x7);
   for (byte x=0;x<DISPLAYS_ACROSS;x++) {
     for (byte y=0;y<DISPLAYS_DOWN;y++) {
      dmd.drawString(  2+(32*x),  1+(16*y), "score", 5, GRAPHICS_NORMAL );
      dmd.drawString(  14+(32*x),  9+(16*y), "3", 1, GRAPHICS_NORMAL );
     }
   }
    delay( 2000 );
  }

//four
  void four()
{
 
   // display some text
   dmd.clearScreen( true );
   dmd.selectFont(SystemFont5x7);
   for (byte x=0;x<DISPLAYS_ACROSS;x++) {
     for (byte y=0;y<DISPLAYS_DOWN;y++) {
      dmd.drawString(  2+(32*x),  1+(16*y), "score", 5, GRAPHICS_NORMAL );
      dmd.drawString(  14+(32*x),  9+(16*y), "4", 1, GRAPHICS_NORMAL );
     }
   }
     delay( 2000 );
  }

//five
  void five()

{
 
   // display some text
   dmd.clearScreen( true );
   dmd.selectFont(SystemFont5x7);
   for (byte x=0;x<DISPLAYS_ACROSS;x++) {
     for (byte y=0;y<DISPLAYS_DOWN;y++) {
      dmd.drawString(  2+(32*x),  1+(16*y), "score", 5, GRAPHICS_NORMAL );
      dmd.drawString(  14+(32*x),  9+(16*y), "5", 1, GRAPHICS_NORMAL );
     }
   }
     delay( 2000 );
  }

//six
  void six()

{
 
   // display some text
   dmd.clearScreen( true );
   dmd.selectFont(SystemFont5x7);
   for (byte x=0;x<DISPLAYS_ACROSS;x++) {
     for (byte y=0;y<DISPLAYS_DOWN;y++) {
      dmd.drawString(  2+(32*x),  1+(16*y), "score", 5, GRAPHICS_NORMAL );
      dmd.drawString(  14+(32*x),  9+(16*y), "6", 1, GRAPHICS_NORMAL );
     }
   }
  delay( 2000 );
  }
//seven
  void seven()

{
 
   // display some text
   dmd.clearScreen( true );
   dmd.selectFont(SystemFont5x7);
   for (byte x=0;x<DISPLAYS_ACROSS;x++) {
     for (byte y=0;y<DISPLAYS_DOWN;y++) {
      dmd.drawString(  2+(32*x),  1+(16*y), "score", 5, GRAPHICS_NORMAL );
      dmd.drawString(  14+(32*x),  9+(16*y), "7", 1, GRAPHICS_NORMAL );
     }
   }
     delay( 2000 );
  }
//eight
  void eight()
{
 
   // display some text
   dmd.clearScreen( true );
   dmd.selectFont(SystemFont5x7);
   for (byte x=0;x<DISPLAYS_ACROSS;x++) {
     for (byte y=0;y<DISPLAYS_DOWN;y++) {
      dmd.drawString(  2+(32*x),  1+(16*y), "score", 5, GRAPHICS_NORMAL );
      dmd.drawString(  14+(32*x),  9+(16*y), "8", 1, GRAPHICS_NORMAL );
     }
   }
    delay( 2000 );
  }

//nine
  void nine()
{
 
   // display some text
   dmd.clearScreen( true );
   dmd.selectFont(SystemFont5x7);
   for (byte x=0;x<DISPLAYS_ACROSS;x++) {
     for (byte y=0;y<DISPLAYS_DOWN;y++) {
      dmd.drawString(  2+(32*x),  1+(16*y), "score", 5, GRAPHICS_NORMAL );
      dmd.drawString(  14+(32*x),  9+(16*y), "9", 1, GRAPHICS_NORMAL );
     }
   }
    delay( 2000 );
  }
//ten
  void ten()
{
 
   // display some text
   dmd.clearScreen( true );
   dmd.selectFont(SystemFont5x7);
   for (byte x=0;x<DISPLAYS_ACROSS;x++) {
     for (byte y=0;y<DISPLAYS_DOWN;y++) {
      dmd.drawString(  2+(32*x),  1+(16*y), "score", 5, GRAPHICS_NORMAL );
      dmd.drawString(  14+(32*x),  9+(16*y), "10", 1, GRAPHICS_NORMAL );
     }
   }
     delay( 2000 );
  }

    //dmd excel codes
 

//win
  void win()
{
 
   // display some text
   dmd.clearScreen( true );
   dmd.selectFont(SystemFont5x7);
   for (byte x=0;x<DISPLAYS_ACROSS;x++) {
     for (byte y=0;y<DISPLAYS_DOWN;y++) {
      dmd.drawString(  2+(32*x),  1+(16*y), "You", 3, GRAPHICS_NORMAL );
      dmd.drawString(  2+(32*x),  9+(16*y), "Win", 3, GRAPHICS_NORMAL );
     }
   }
  delay( 2000 );
  }
  


void loop()

{

int distance = 0;

int ir0 = analogRead(A0);
int ir1 = analogRead(A1);
int ir2 = analogRead(A2);
int ir3 = analogRead(A3);
int ir4 = analogRead(A4);
pinMode (ir0, INPUT);
pinMode (ir1, INPUT);
pinMode (ir2, INPUT);
pinMode (ir3, INPUT);
pinMode (ir4, INPUT);

     Serial.println();
     Serial.println("ir0");
     Serial.println(ir0);
     Serial.println();
     Serial.println("----------------------------------------");
     Serial.println();
     Serial.println("ir1");
     Serial.println(ir1);
     Serial.println();
     Serial.println("----------------------------------------");
     Serial.println();
     Serial.println("ir2");
     Serial.println(ir2);
     Serial.println();
     Serial.println("----------------------------------------");
     Serial.println();
     Serial.println("ir3");
     Serial.println(ir3);
     Serial.println();
     Serial.println("----------------------------------------");
     Serial.println();
     Serial.println("ir4");
     Serial.println(ir4);
     Serial.println();
     Serial.println("----------------------------------------");
     Serial.println();
     Serial.println("score");
     Serial.println(score);
     Serial.println();
     Serial.println("----------------------------------------");
      


    //relay code pin 3
    
 //if (analogRead(A0) > 500)
//{  score++;

   
if ((analogRead(A0) > 500) || (analogRead(A1) > 500) || (analogRead(A2) > 500) || (analogRead(A3) > 500)|| (analogRead(A4) > 500))  //may replace irx with distance
{score++;

              digitalWrite(relay,HIGH);    // 1. turns on
        delay(5000);             // 2. waits 500 milliseconds (0.5 sec). Change the value in the brackets (500) for a longer or shorter delay in milliseconds.
      digitalWrite(relay,LOW);      // 3. turns off.
          delay(500);             // 4. waits 500 milliseconds (0.5 sec). Change the value in the brackets (500) for a longer or shorter delay in milliseconds.
 }
 
{

if (score == 0)
{zero();                
}

if (score == 1)
{one();                
}

if (score == 2)
{two();                
}


if (score == 3)
{three();    

            
if (score == 4)
{four();                
}


if (score == 5)
{five();                
}


if (score == 6)
{six();                
}


if (score == 7)
{seven();                
}


if (score == 8)
{eight();                
}


if (score == 9)
{nine();                
}


if (score == 10)
{ten();
                
delay (5000);
win();
}

          

}}}



KegRaider
Posts: 15
Joined: Sun Sep 09, 2012 12:08 am

Re: dmd stops refreshing after third image

Post by KegRaider » Wed Dec 07, 2016 8:51 pm

Hey mate,

at a quick glance, currently in the airport departure lounge, it appears you are missing a closing brace ";}" after the three in the scoring section. i hope its this easy to fix :)

KegRaider

KegRaider
Posts: 15
Joined: Sun Sep 09, 2012 12:08 am

Re: dmd stops refreshing after third image

Post by KegRaider » Sat Dec 10, 2016 7:50 am

Hi again JediHermit,

Unfortunately I am not near a computer that I am able to install the Arduino compiler on (corporate machines with Digital Guardian enabled), so I can only offer typo's where I see them I guess.

Code: Select all

if (score == 3)
{three();    
}  
And

Code: Select all

if (score == 10)
{ten();
}
                
delay (5000);
{win();
}
Those stick out for me. Unless you wanted the 10 and Win to be in the same call?
Thanks again for the spreadsheet DMD tool, much easier!

Post Reply