Dot Matrix Display

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
debenham
Posts: 33
Joined: Tue Jan 10, 2012 3:22 am

Re: Dot Matrix Display

Post by debenham » Wed Jan 18, 2012 1:36 am

I have been working on the library and made a number of changes - including multi-display support and a full scrolling marquee.
Have a look at viewtopic.php?f=26&t=153
The modified library is available from my github repo as https://github.com/cjd/DMD

I've just uploaded a video of the demo to youtube as http://youtu.be/5DLmWrpV-3M

EpicTinker
Posts: 9
Joined: Thu Nov 03, 2011 4:36 pm

Re: Dot Matrix Display

Post by EpicTinker » Wed Jan 18, 2012 7:18 am

Awesome!! :D

cpohara
Posts: 9
Joined: Sat Feb 11, 2012 5:15 am

Re: Dot Matrix Display

Post by cpohara » Sat Feb 11, 2012 5:36 am

Hey All

I've got a little project underway and want to use the DMD to display what I need.

I am NOT a programmer and I have strung together some code from various examples and then had a friend turn it into something a real programmer might write. But anyways, I have most of my output displaying successfully on an LCD screen but I am finding it difficult to do the same with the DMD, primarily because it doesn't seem like I can print ints, only char - is this right?

In my game i keep running scores for 2 teams and display them both, along with some other messages that are non essential but intended for fun. I'd really like to get the scores displaying and updating on the DMD without doing complicated coding. Hope you guys can help...

here is a link to my project
https://sites.google.com/site/saposcore/

here is the main code. sorry about the comments, i am trying to teach myself how this stuff work:

Code: Select all

#include "DigitalInput.h"
#include "ScoreTrigger.h"
#include <LiquidCrystal.h>
#include <SPI.h>        //SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include <DMD.h>        //
#include <TimerOne.h>   //
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#include "Arial14.h"

DMD dmd(1,1);

int NUM_SCORE_TRIGGERS = 0;          // setting this variable to 0 to start, it will be assigned to a different little later

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

CScoreTrigger ScoreTriggers[] = {    //this is an array of [] (unknown) number of items
  CScoreTrigger(4, 500),             //item #1 in this array 
  CScoreTrigger(3, 1000),            //item #2 in this array 
};

CDigitalInput TurnPin(2);            

LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);  
int Score[2] = {0 , 0};                 
int TurnIndex = 0;                      
int NumPlayers = 2;
boolean goodshot = false;
String whosturn = "Team 1";
String greeting = "Nice Shot! ";
char dmdtest[] = "SAPO!";

void setup() {
  
      NUM_SCORE_TRIGGERS = sizeof(ScoreTriggers)/sizeof(ScoreTriggers[0]);  

	                            
	TurnPin.Init();             

	for (int i = 0; i < NUM_SCORE_TRIGGERS; i++)  
	{
		ScoreTriggers[i].Init();              

	}


   Timer1.initialize( 5000 );
   Timer1.attachInterrupt( ScanDMD );   
   dmd.clearScreen( true );   //true is normal (all pixels off), false is negative (all pixels on)
   dmd.selectFont(SystemFont5x7);
   dmd.drawString(  1,  1, dmdtest , 5, GRAPHICS_NORMAL );

   

	lcd.begin(16, 2);
	lcd.setCursor(0,0);
	lcd.print("Welcome to Sapo!");
	delay(3000);
	lcd.clear();
	lcd.setCursor(0,0);
	lcd.print(whosturn);
	lcd.setCursor(0,1);
	lcd.print("You're up!");
	delay(2000);


}


//
// Loop
// 

void loop() {
	
	TurnPin.UpdateState();

	for (int i = 0; i < NUM_SCORE_TRIGGERS; i++)
	{
		ScoreTriggers[i].UpdateState();
	}

    // Handle players switch
	if (TurnPin.ChangedState(HIGH))
	{
		
		TurnIndex += 1;
                TurnIndex %= NumPlayers;

		if (TurnIndex == 0)
		{
			whosturn = "Team 1";
		}
		else
		{
			whosturn = "Team 2";
		}

		//what to print for a team change       
		
                dmd.clearScreen( true );   //true is normal (all pixels off), false is negative (all pixels on)
                dmd.selectFont(System5x7);
                dmd.drawString(  2,  1, whosturn, 4, GRAPHICS_NORMAL );
                dmd.drawString(  0,  9, "GO!", 6, GRAPHICS_NORMAL );
                
                lcd.clear(); 
		lcd.print("Team Change!");
		lcd.setCursor(0,1);
		lcd.print("Next:  ");
		lcd.print(whosturn); 
		delay(1000);  
	}
	else if(TurnPin.ChangedState(LOW))
	{
		lcd.clear(); 
		lcd.setCursor(0,0);
		lcd.print(whosturn);
		lcd.print(" - GO!        ");
	}

	// Handle score
	for (int i = 0; i < NUM_SCORE_TRIGGERS; i++)
	{
		if (ScoreTriggers[i].ChangedState(HIGH))
		{
				
			/// Add Score
                        int nPointValue =ScoreTriggers[i].GetPointValue();
			Score[TurnIndex] += nPointValue;
	  
			//set the greeting to mention points
			goodshot = true;
			greeting = "Yes! ";			
			greeting += nPointValue;
			greeting += "!";

dmd.clearScreen( true );   //true is normal (all pixels off), false is negative (all pixels on)
              dmd.selectFont(SystemFont5x7);
              dmd.drawString(  0,  0, greeting, 5, GRAPHICS_NORMAL );
                        
		}
		else if (ScoreTriggers[i].ChangedState(LOW))
                
		{			
              dmd.clearScreen( true );   //true is normal (all pixels off), false is negative (all pixels on)
              dmd.selectFont(SystemFont5x7);
              dmd.drawString(  0,  0, whosturn, 5, GRAPHICS_NORMAL );
              dmd.drawString( 0,  9, "GO!", 5, GRAPHICS_NORMAL );

  	      lcd.setCursor(0,0);
	      lcd.print(whosturn);
	      lcd.print(" - GO!          ");
		}
	}
	
	//if a shot was made, print the following:
	if (goodshot == true)
	{

      dmd.clearScreen( true );   //true is normal (all pixels off), false is negative (all pixels on)
      dmd.selectFont(SystemFont5x7);
      dmd.drawString(  3,  0, Score[0], 5, GRAPHICS_NORMAL );
      dmd.drawString(  3,  9, Score[1], 5, GRAPHICS_NORMAL );

          //lcd.clear();
          lcd.setCursor(0,0);
          lcd.print(greeting);
          lcd.setCursor(0,1);
          lcd.print("1:");
          lcd.print(Score[0]);
          lcd.print(" ");
          lcd.print("2:");
          lcd.print(Score[1]);
          lcd.print(" ");
          goodshot=false;
          delay(1000);
        }
}


debenham
Posts: 33
Joined: Tue Jan 10, 2012 3:22 am

Re: Dot Matrix Display

Post by debenham » Sun Feb 12, 2012 9:16 pm

If you need to output numbers you can use the 'itoa()' function to convert a number to a string.
For example:

Code: Select all

#include <stdlib.h>

void setup ()
{
  Serial.begin(9600);
  char scoretext1[5];
  char scoretext2[5];
  int score1 = 12;
  int score2 = 8;
  itoa(score1,scoretext1,10);
  itoa(score2,scoretext2,10);
  Serial.println(scoretext1);
  Serial.println(scoretext2);
}

If you want I can give you a hand with that program (I can see it coming in handy for my youth group as well ;) )
Is the source code to your program anywhere I could see it? (I had a look at your site but couldn't find it)

cpohara
Posts: 9
Joined: Sat Feb 11, 2012 5:15 am

Re: Dot Matrix Display

Post by cpohara » Mon Feb 13, 2012 3:11 am

Thanks for the reply, through some other forums I also discovered sprintf and now I've got everything displaying the way I want to. I even hooked up the switches to the game board and I've started wiring all that (lots of wires). I made surprising progress today.

I'll paste new pictures and all my code to the site this week so you can check it out.

I have a few questions at this point.

1. I am out of pins, because of the DMD i only have 4 digital pins and 6 analog and I need 11 (10 unique score values and 1 team switch). Any advice? Can I use pins 0 or 1?

2. I really want a 3x5 font so i can display both teams scores plus some fun messaging. Right now its a little dry, but does the job. I haven't been able to find any and I tried to modify and hack the system font 5x7 but it just never worked out. I don't think I grasp all the setup that is being done in the .h file.

3. Also, the score goes to negative after 32,000. I figure this is a memory size issue of some kind, but I don't know how to fix.

Thanks!!

debenham
Posts: 33
Joined: Tue Jan 10, 2012 3:22 am

Re: Dot Matrix Display

Post by debenham » Mon Feb 13, 2012 3:26 am

1. I am out of pins, because of the DMD i only have 4 digital pins and 6 analog and I need 11 (10 unique score values and 1 team switch). Any advice? Can I use pins 0 or 1?

Pins 0 and 1 are normally used for Serial - so you would need to make sure you don't use 'Serial.begin()' or any Serial commands. As long as you are careful on that you can use pins 0/1 as input
The other option is to use an input shift chip - see http://www.arduino.cc/en/Tutorial/ShiftIn for an example

2. I really want a 3x5 font so i can display both teams scores plus some fun messaging. Right now its a little dry, but does the job. I haven't been able to find any and I tried to modify and hack the system font 5x7 but it just never worked out. I don't think I grasp all the setup that is being done in the .h file.

If you are using my version of the library (https://github.com/cjd/DMD) you can create a little font like that using GLCDFontCreator - see https://code.google.com/p/glcd-arduino/ ... eator2.zip
That tool can convert a ttf font to a suitable .h file

3. Also, the score goes to negative after 32,000. I figure this is a memory size issue of some kind, but I don't know how to fix.

This is due to storing the score in an 'int'
A normal int is only 2 bytes and so can be between -32k and 32k
If you use 'unsigned int' instead it will be between 0 and 64k
If you need even more range change your code to use 'long' as the type instead

cpohara
Posts: 9
Joined: Sat Feb 11, 2012 5:15 am

Re: Dot Matrix Display

Post by cpohara » Mon Feb 13, 2012 4:13 am

Awesome, thanks for the help!!

1. Sounds good, i'll give it a try!
2. Yes, i'm using your library. I must be missing something, how do I use the font creator? I actually came across this in my search but didn't know what to do with it ;)
3. Perfect, thanks!

Edit:

update to #2: I downloaded it from http://www.mikroe.com/eng/products/view ... t-creator/. Hope it works.

JRThro
Posts: 5
Joined: Tue Jan 24, 2012 4:46 am

Re: Dot Matrix Display

Post by JRThro » Mon Feb 13, 2012 5:53 pm

I finally hooked up my DMD to my EtherTen last night.

It was amazingly easy to get things working. Including downloading and copying the necessary libraries, it probably only took about 5 minutes until I was running and modifying the DMD demo sketch to say "Lotsa fun!" instead of "freetronic", and having it draw 4 concentric circles where there was only 1 before.

And yes, the LEDs are *more* than bright enough without an external 5 VDC supply.

Now I need to look at scrolling some text as discussed above, for this coming Saturday's Cub Scout Blue and Gold Banquet. That should be fun!

My final goal is to put together a sketch for a clock similar to tronixstuff's Clock One but different enough to consider it my own design.

debenham
Posts: 33
Joined: Tue Jan 10, 2012 3:22 am

Re: Dot Matrix Display

Post by debenham » Mon Feb 13, 2012 9:37 pm

cpohara wrote:Awesome, thanks for the help!!

1. Sounds good, i'll give it a try!
2. Yes, i'm using your library. I must be missing something, how do I use the font creator? I actually came across this in my search but didn't know what to do with it ;)
3. Perfect, thanks!

Edit:

update to #2: I downloaded it from http://www.mikroe.com/eng/products/view ... t-creator/. Hope it works.
That download is a slightly different one (and only runs on windows) where as the one noted before is a java app
To use it run 'start.bat' on windows or 'java -classpath . FontCreator' on any other system.
Mind you I had a look at it and if you are planning on making a 3x5 font you will pretty much have to design it yourself since most chars don't fit readably in that sort of size (for example W) and lowercase characters won't really be possible. You will need to do at least 5x5 to fit chars like M and W

cpohara
Posts: 9
Joined: Sat Feb 11, 2012 5:15 am

Re: Dot Matrix Display

Post by cpohara » Tue Feb 14, 2012 2:45 am

Yeah i will probably only use numbers for the 3x5.

I will probably try thisout tonight, will I need to do anything with the outputted C code other than put itin an h file and onclude ot in my code?

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests