Instructables

Multiple LED Matrices with Arduino

Picture of Multiple LED Matrices with Arduino
IMG_20130820_194111.jpg
This project is based on a workshop that we organised at Makespace Madrid as part of  "La noche de la electrónica con Jameco".  In a previous instructable we already introduced how to manage a single LED matrix with Arduino. In this project we connect multiple matrices to display text  messages.

It is recommended that you have followed the previous instructable before you do this one.



 
Remove these adsRemove these ads by Signing Up

Step 1: Components

Picture of Components
For this project, you need the following components:
- Arduino Uno board
- 4 MAX7219 Red Dot Matrix Module
- 17  jumper wires M/M (male/male)
- 3 jumper wires F/M (female/male)
- Breadboard

Although this instructable uses an Arduino Uno board, you can use other Arduino (compatible) boards

IMPORTANT: The LED matrix is common cathode. This module does not work with common anode matrices.

Step 2: Arduino Library

If you have not installed the Arduino library yet (LEDControlMS), do it now. You can find the library and the installation instructions here.
verdelj1 month ago

I finally got around to work on you library. I added two new characters or figures. its very easy to create new characters but it is a little bit time consuming. I will try two make more when I get a chance probably lowercase and all special characters plus a few figures, happy face, skulls, flowers, hearts...ect

once again thanks for taking the time to answer my questions.

{0x3,0x4,0xF8,0x4,0x3,0x0},//Y

{0xE1,0x91,0x89,0x85,0x83,0x0},//Z

{0x72,0x89,0x89,0x91,0x7E,0x00}, //@

{0x1C,0xF6,0x5F,0x5F,0xF6,0x1C}, //Skull

{0x3E,0x42,0x84,0x84,0x42,0x3E} //heart

tumaku (author)  verdelj1 month ago
Great:-) Glad that you were able to update the library/skecth by yourself!
It is tedious, but you learn a lot of binary/hexadecimal coding...
verdelj4 months ago
Your library is incomplete you are missing the forecasts letters and some special characters ex" @ " I need the @and some lower case can you please tell me how i can add them. Thank you.
tumaku (author)  verdelj3 months ago

You can add new chars by addind their binary representation to the alphabetBitmap array in LEDControlMS.h file

Every new character is represented by 6 byes (each byte corresponds to one column of 8 bits/pixels). Note that also have to change the size of the array (the current version of the library has 41 characters -> alphabetBitmap[41][6]

Finally you must also update the method int LedControl::getCharArrayPosition(char input) in LEDControlMS.cpp to consider the new characters that you have added to the array.

verdelj tumaku3 months ago
I tried but i.just couldnt get it to work and i search the whole web but only found arrays with 7 and 8 bytes. Like I said before my programming skills are very limited. The charracter that I need is "@" what would be the binary representation in 6 bytes
tumaku (author)  verdelj3 months ago

It is not difficult, but it is not straightforward to explain how to code a new char. It is basically binary/hexadecimal coding of a pixel image/character.

I have handdrawn a picture of character 'G' and its coding:

0x7E,0x81, 0x81,0x91,0x72,0x00

And I have also created character '@' in the same way:

0x72,0x89,0x89,0x91,0x7E,0x00

Note that this coding is required for this specific library. Other libraries might code the images in a diffferent way/order.

Hope this helps!

IMG_20140503_191136.jpg
verdelj tumaku2 months ago

Now it makes alot of sense, the only question I have is what do I have to do to LedControl::getCharArrayPosition(char input) in LEDControlMS.cpp

I am a little bit lost

int LedControl::getCharArrayPosition(char input){

if ((input==' ')||(input=='+')) return 10;

if (input==':') return 11;

if (input=='-') return 12;

if (input=='.') return 13;

if ((input =='(')) return 14; //replace by 'ñ'

if ((input >='0')&&(input <='9')) return (input-'0');

if ((input >='A')&&(input <='Z')) return (input-'A' + 15);

if ((input >='a')&&(input <='z')) return (input-'a' + 15);

return 13;

}

lets say that I wanted to add "@" to the library how would I need to modify this? and do I need to modify for every letter that I add?

tumaku (author)  verdelj2 months ago

The simplest way is to add the byte string at the end of the char array in the library. Note that you also need to change the array dimension!

const static byte alphabetBitmap[42][6]={
{0x7E,0x81,0x81,0x81,0x7E,0x0}, //0
...
{0xE1,0x91,0x89,0x85,0x83,0x0},//Z

{0x72,0x89,0x89,0x91,0x7E,0x00} //@
};

Then on the LedControl::getCharArrayPosition(char input) method, add one line for the "@" char:

if (input=='@') return 41;

That should work...

verdelj tumaku2 months ago

return 41? what does 41 mean?

tumaku (author)  verdelj2 months ago

The data for "@" has been added at position 41 of the array (the initial index is 0).

If you now add a new character definition, the array will be

const static byte alphabetBitmap[43][6]={...

and the getCharArrayPosition() method should be updated with:

if (input==' ') return 42;

verdelj tumaku2 months ago

thanks a million now It all makes sense, will try to update it this weekend. thank you for your time

tumaku (author)  verdelj2 months ago

The data for "@" has been added at position 41 of the array (the initial index is 0).

If you now add a new character definition, the array will be

const static byte alphabetBitmap[43][6]={...

and the getCharArrayPosition() method should be updated with:

if (input==' ') return 42;

verdelj tumaku3 months ago
Thanks will try to update the library this weekend.
verdelj3 months ago

you have it wrong should be

#include "LedControlMS.h"

not

#include "LEDControlms.h"

tumaku (author)  verdelj3 months ago

Thanks verdelj! You are right, the problem is that th Arduino IDE cannot find the library because of the wrong name (the library name is case sensitive)

ycho43 months ago

hey coding seems like has no problem but then I have this weired error compiling.

Do you know what is the problem?

Interface_Final.cpp.o: In function `__static_initialization_and_destruction_0':

/Applications/Interface_Final.ino:4: undefined reference to `LedControl::LedControl(int, int, int, int)'

Interface_Final.cpp.o: In function `displayString(String, short)':

/Applications/Interface_Final.ino:40: undefined reference to `LedControl::getCharArrayPosition(char)'

/Applications/Interface_Final.ino:40: undefined reference to `LedControl::displayChar(int, int)'

/Applications/Interface_Final.ino:41: undefined reference to `LedControl::getCharArrayPosition(char)'

/Applications/Interface_Final.ino:41: undefined reference to `LedControl::displayChar(int, int)'

/Applications/Interface_Final.ino:42: undefined reference to `LedControl::getCharArrayPosition(char)'

/Applications/Interface_Final.ino:42: undefined reference to `LedControl::displayChar(int, int)'

/Applications/Interface_Final.ino:47: undefined reference to `LedControl::clearAll()'

/Applications/Interface_Final.ino:52: undefined reference to `LedControl::clearAll()'

Interface_Final.cpp.o: In function `setup':

/Applications/Interface_Final.ino:17: undefined reference to `LedControl::shutdown(int, bool)'

/Applications/Interface_Final.ino:18: undefined reference to `LedControl::setIntensity(int, int)'

/Applications/Interface_Final.ino:19: undefined reference to `LedControl::clearDisplay(int)'

/Applications/Interface_Final.ino:22: undefined reference to `LedControl::clearAll()'

here's my coding

#include "LEDControlms.h"

#define NBR_MTX 4

LedControl lc=LedControl(12,11,10, NBR_MTX);

String scrollString1= "INTERFACE CLASS ";

String scrollString2= "MOVE IT SLOW ";

String scrollString3= "AND MOVE IT FAST ";

char ch0, ch1, ch2;

void setup() {

Serial.begin(9600);

Serial.println("Setup");

for (int i=0; i< NBR_MTX; i++){

lc.shutdown(i,false);

lc.setIntensity(i,1);

lc.clearDisplay(i);

}

delay(1000);

lc.clearAll();

}

void loop() {

Serial.println(scrollString1);

displayString(scrollString1,500);

Serial.println(scrollString2);

displayString(scrollString2,1000);

Serial.println(scrollString3);

displayString(scrollString3,200);

}

void displayString(String displayString, short speed) {

short nextCharIndex=3;

ch0= displayString[0];

ch1= displayString[1];

ch2= displayString[2];

while (true) {

lc.displayChar(0, lc.getCharArrayPosition(ch0));

lc.displayChar(1, lc.getCharArrayPosition(ch1));

lc.displayChar(2, lc.getCharArrayPosition(ch2));

ch0=ch1;

ch1=ch2;

ch2=displayString[nextCharIndex++];

if (ch2==0) {

lc.clearAll();

delay(25);

return;

}

delay(speed);

lc.clearAll();

delay(25);

}

}

DavidFJ3 months ago

where did i can download the code?

tumaku (author)  DavidFJ3 months ago

There are links to code files in Steps 2 and 6

tumaku (author)  DavidFJ3 months ago

There are links to code files in Steps 2 and 6

verdelj4 months ago

the code worked great I just had to modify it a little because i am using 5. I play the accordion and I want to add the led matrix to the front on the accordion and display some info and also want to have an audio spectrum analyzer and a mic so that when I start to play ill have so graphics on the matrix. my programming skills are very limited like I said before but I researching and looking for some code for the analyzer. I plan to have two buttons one for the power and then one to cycle the display example push once " Gabbanelli " another push and " name and phone # " another push spectrum analyzer.

this picture is from a few days ago of the when I was making the base for my leds I will post a full instructable of the finish accordion when I am done mounting it and painting it.

thank you for all the help. I repair accordions as a hobby but I am a diesel mechanic so if you ever need to know anything about accordions of cars let me know.

securedownload.jpg
verdelj4 months ago
Thanks a million, that's exactly what I need it, I will try it out tomorrow and let you know. Thanks again
tumaku (author) 4 months ago

Thanks for your message!

I do not know how I can help you. If you have concrete questions, I will try to answer them.

The good thing about these max7219 modules is that you do not need to refresh the matrices at regular intervals so you can "isolate" your code form the matrices.

verdelj tumaku4 months ago
I want to dispay, some messages lets say 3 messages but all 3 using different scrolling speeds how can I complish that. Display " hello" delay 500 once done dispay " have a nice day" delay 1000 then "welcome back" delay 500. Like I said my programming skills are very limited I need an example. I have been looking around but haven't found alot of info. Thanks for the reply.
tumaku (author)  verdelj4 months ago

I have not been able to test this (I do not have the matrices with me now), but this should work with three different strings moving at different speeds. You define the "speed" in the second parameter that you pass to displayString() function.

In C, Strings are finished with a null character (0). That is the trigger that I use to exit the displayString() function.

//We always have to include the library
#include "LedControlMS.h"

/*
Now we need a LedControl to work with.
pin 12 is connected to the DataIn
pin 11 is connected to the CLK
pin 10 is connected to LOAD
We have only a single MAX72XX.
*/
#define NBR_MTX 4
LedControl lc=LedControl(12,11,10, NBR_MTX);

String scrollString1= "MAKESPACE MADRID ";
String scrollString2= "THIS MOVES SLOWER ";
String scrollString3= "AND THIS MOVES FASTER ";

char ch0, ch1, ch2, ch3;

void setup() {
/*
The MAX72XX is in power-saving mode on startup,
we have to do a wakeup call
*/
Serial.begin (9600);
Serial.println("Setup");


for (int i=0; i< NBR_MTX; i++){
lc.shutdown(i,false);
/* Set the brightness to a low value */
lc.setIntensity(i,1);
/* and clear the display */
lc.clearDisplay(i);
}
delay(100);
lc.clearAll();
}

void loop(){
Serial.println(scrollString1);
displayString(scrollString1,500);
Serial.println(scrollString2);
displayString(scrollString2,1000);
Serial.println(scrollString3);
displayString(scrollString3,200);
}

void displayString(String displayString, short speed){
short nextCharIndex=4;
ch0= displayString[0];
ch1= displayString[1];
ch2= displayString[2];
ch3= displayString[3];
while (true) {
lc.displayChar(0, lc.getCharArrayPosition(ch0));
lc.displayChar(1, lc.getCharArrayPosition(ch1));
lc.displayChar(2, lc.getCharArrayPosition(ch2));
lc.displayChar(3, lc.getCharArrayPosition(ch3));
ch0=ch1;
ch1=ch2;
ch2=ch3;
ch3=displayString[nextCharIndex++];
if (ch3==0) {// end of string
lc.clearAll();
delay(25);
return;
}
delay(speed);
lc.clearAll();
delay(25);
}
}

verdelj4 months ago
Great instructable, I am a begginer and I build a 32x8 matrix using the 4 max7219 modules just like in your instructable, I have an idea for a project but after reading a lot of articles and tutorials. I still don't understand the code to the point where I can write my own program can you please help me.
Yonnis10 months ago
(removed by author or community request)
tumaku (author)  Yonnis10 months ago
LEDCONTROR  ??? With an R at the end?
The class name is  LedControl

If this is a typo in your message, maybe the problem is that you have not installed the library in the right folder (or that you have not restarted Arduino IDE). Please check the instructions in the previous instructable.
Yonnis tumaku10 months ago
Thanks Tumaku