New MAX72xx Playground Article

Hello to those in the matrix,

I just posted a "How To" in the Playground - "Multiplexing the MAX72xx to drive a 2 Color Matrix".
(It's linked from the "MAX7219 and MAX7221" section.)

It's my first Wiki, so I hope I did it correctly. I'll be happy to tweak it.

Also hope some find it useful.

[edit]
http://www.arduino.cc/playground/Main/MultiplexMAX72xx

Thanks Brohogan!

The link for the lazy ones..
http://www.arduino.cc/playground/Main/MultiplexMAX72xx

How would you say this differs from the 2 already existing codes in the playground? (not counting the org matrix-library)

hello,

nice code.

It doesn't compile well here... (Wiring environment + Wiring board)
I tested basically.. the first error was "wirig.h doesn't exist" or something like that
indeed, in Wiring environment the same library is TwoWire.h
I add the Wire lib from arduino to Wiring env... no problem for that.

But it remains some strange things:

libraries/MsTimer2/MsTimer2.h:11: error: 'boolean' does not name a type
MsTimer2.cpp:30: error: 'boolean' does not name a type
MsTimer2.cpp: In function 'void MsTimer2::set(long unsigned int, void (*)())':
MsTimer2.cpp:33: error: 'TCCR2B' was not declared in this scope
MsTimer2.cpp:35: error: 'TCCR2A' was not declared in this scope
MsTimer2.cpp:36: error: 'WGM22' was not declared in this scope
MsTimer2.cpp:37: error: 'AS2' was not declared in this scope
MsTimer2.cpp:38: error: 'TIMSK2' was not declared in this scope
MsTimer2.cpp:38: error: 'OCIE2A' was not declared in this scope
MsTimer2.cpp: In function 'void MsTimer2::start()':
MsTimer2.cpp:49: error: 'overflowing' was not declared in this scope
MsTimer2.cpp:51: error: 'TIMSK2' was not declared in this scope
MsTimer2.cpp: In function 'void MsTimer2::stop()':
MsTimer2.cpp:55: error: 'TIMSK2' was not declared in this scope
MsTimer2.cpp: In function 'void MsTimer2::_overflow()':
MsTimer2.cpp:61: error: 'overflowing' was not declared in this scope
o: In function `ClearMatrix()':
undefined reference to `MsTimer2::stop()'o: In function `SetColumn(unsigned char, unsigned char, unsigned char)':
o: In function `SetRow(unsigned char, unsigned char, unsigned char)':
o: In function `SetLed(unsigned char, unsigned char, unsigned char, unsigned char)':
o: In function `setup':

could someone help me ?

Works just fine with my Arduino Dec.

Remember, you need the LEDControl Library:
http://www.arduino.cc/playground/Main/LedControl

And the MsTimer2:
http://www.arduino.cc/playground/Main/MsTimer2

ok it helps :wink:
I'm trying to troubleshoot the thing..

of course, I imported these 2 libs before the tests :slight_smile:

on my computer, with Arduino environment: it compiles fine!
Of course, I cannot use it to upload the code to my ... Wiring board :cry:

it is probably a path/code problem :frowning:

FrequencyTimer2 doesn't give a correct compilation too :frowning:

in the beginning of the MsTimer2.h:

MsTimer2.h - Using timer2 with 1ms resolution

  • Javier Valencia jvalencia@log01.org*

  • History:*

  • 10/May/08 - V0.2 added some security tests and volatile keywords*
    _ 9/May/08 - V0.1 released working on ATMEGA168 only_

it can't work on the Wiring Board indeed...
I couldn't alter the lib to work with it and I'm sad :cry:

Im trying to edit the togShutdown to work with 3 max's, but i dont get why this wont work. Any ideas?
The debugging tells me: error: expected primary-expression before 'else'
(the second else statement. wich imo, shouldnt cause any problems)

void togShutdown(void) {    //This ISR toggles shutdown between the 2 MAX7221's
  if(maxInShutdown==GREEN){
    lc.shutdown(RED,true);
    lc.shutdown(BLUE,true);
    lc.shutdown(GREEN,false);
    maxInShutdown=RED;
    maxInShutdown=BLUE;
  }
  else {
    lc.shutdown(GREEN,true);
    lc.shutdown(BLUE,true);
    lc.shutdown(RED,false);
    maxInShutdown=GREEN;
    maxInShutdown=BLUE;
  }
  else {
    lc.shutdown(RED,true);
    lc.shutdown(GREEN,true);
    lc.shutdown(BLUE,false);
    maxInShutdown=RED;
    maxInShutdown=GREEN;
  }
}

steffensen,

Your second else needs to be an "else if".
http://www.arduino.cc/en/Reference/Else

With 3 colors,, you should probably reverse the logic anyway since there will always be 2 in shutdown.
You might also try a switch statement, although I've never used one in an ISR.

Ah, i did read the Reference, but i totally missed the else if.
Gonna try your recomendations, thanks!

Im not sure what you mean by reverse logic, do you mean something like this?

void togShutdown(void) {    //This ISR toggles shutdown between the 2 MAX7221's
  if(maxInShutdown==GREEN){
    lc.shutdown(RED,true);
    lc.shutdown(BLUE,true);
    lc.shutdown(GREEN,false);
    maxInShutdown=RED;
  }
  else if(maxInShutdown==RED) {
    lc.shutdown(GREEN,true);
    lc.shutdown(BLUE,true);
    lc.shutdown(RED,false);
    maxInShutdown=BLUE;
  }
  else if(maxInShutdown==BLUE) {
    lc.shutdown(RED,true);
    lc.shutdown(GREEN,true);
    lc.shutdown(BLUE,false);
    maxInShutdown=GREEN;
  }
}

(only used else if in here, because i wanted to match statements)

I tried a switch statement, but i couldnt get pass the "error: expected unqualified-id before 'switch' In function 'void setup()':"
Havent tried the above written code yet, but as usual, i cant see why it shouldnt work.

Sorry for spamming your topic even more!

I ordered an arduino... :cry: :wink:

I'll have 1 arduino + 1 Wiring board :slight_smile:
So, I'll test it soon (about 10 days, I guess)

I'd like to alter the mstimer2 code for Wiring Board's use... but I'm unable
If someone was interested ...

Just to let you know, i tried this. But didnt work. (yet)
Wasnt sure about the breaks, but i tried both with and without, and no difference.
Anyone brighter than me, feel free to chip in!

void togShutdown(void) {    //This ISR toggles shutdown between the 3 MAX7221's
  switch (maxInShutdown) {
    case RED: 
      lc.shutdown(GREEN,true);
      lc.shutdown(BLUE,true);
      lc.shutdown(RED,false);
      maxInShutdown=GREEN;
      break;
    case GREEN:
      lc.shutdown(RED,true);
      lc.shutdown(BLUE,true);
      lc.shutdown(GREEN,false);
      maxInShutdown=BLUE;
      break;  
    case BLUE: 
      lc.shutdown(RED,true);
      lc.shutdown(GREEN,true);
      lc.shutdown(BLUE,false);
      maxInShutdown=RED;
      }
}

Any chance someone will make a PCB for a shield to hold the MAX72xx's and an easily obtainable LED matrix? It looks like a lot of fun to play with but also a lot of tedious, error-prone soldering to prototype.

Oracle,
Your right. Having prototyped this a couple of times, it is a PITA (difficult) to solder up.

At the bottom of my profile, Arduino Playground - BroHogan I added a picture of a little board I had made that fits behind the Sparkfun RG matrix. Since it only requires 5 wires for SPI, I thought it was better to "shield" the matrix rather than the Arduino. (I did make a 2"x2" "Arduino" that fits behind the matrix shield as well.) The board works well.

I'd be glad to post the Eagle files if there is interest.

A modest little bump for my quest for RGB above. :slight_smile:
What can i be doing wrong here?

I even tried the if/else if/else, as that paul did where this playground article got birth, but no luck.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1206907547/0

Looks to me like both of you guys need help with the programing side of things.

I started this thread simply to announce the playground article.
Best to let it fade away now.

Perhaps you should start a thread of your own in the software section.
I promise I won't hijack it. :wink:

Yes, im quite the beginner with the C side of programming, even tho im quite capable in max/msp.
But im really willing to learn, even tho i do need some help sometimes to understand things. (as of now im dead-stuck)

Sorry for hijacking the thread, i thought it could interest more people than me. Ill start it up in the software section as recomended. Thanks again!