Product Documentation
- LED Products
- Arduino Products
- Audio Products
- Timekeeping Products
- Power Products
- Wire Products
The LED Matrix Shades can scroll custom text messages across the display. If you have the Arduino IDE set up correctly for downloading program updates to the LED Matrix Shades, then it's easy to change the default messages to anything you want. Don't have the Arduino IDE set up? Start here first: Programming Instructions
As described in the Programming Instructions, open the LEDMatrixShades sketch. Before making any changes, it's a good idea to find the Save As…
menu item under the File
menu, and save it with a different name (LEDMatrixShadesTest or something else you'll remember. You should see a window similar to the following (there may be some differences depending on the operating system you use):
Click on the “messages.h” tab and you should see the contents of the messages.h file as below:
The messages are stored inside strings. The characters in between the quote marks will be displayed on the LED Matrix Shades when that particular message is selected. This includes letters, numbers, and punctuation. However, since quote marks are used to indicate the start and end of the message, it's best to avoid using them except as described in the Advanced Topics section below.
If you're satisfied with editing three different messages, then it's very easy! Just replace the original text with your own, leaving everything else alone. In the example below, we'll replace “macetech.com ” with “12345 ”.
When editing messages, you will probably want to add some spaces after the message. Otherwise the next loop of the message will start immediately. With two spaces after the message, it will look like 12345 12345 12345
and so on, but if we leave out the spaces it will look like 123451234512345
instead. This can be useful depending on the message and effect you want.
Assuming that everything was setup up correctly according to Programming Instructions, the next part is easy. Make sure the LED Matrix Shades are plugged into your computer with a USB cable, they are turned on, and the correct serial port is selected. Then press the Upload button in the Arduino IDE, and after a minute of LEDs blinking on the side of the LED Matrix Shades, your message should be programmed into the microcontroller's memory. If there are any errors, go through the Programming Instructions again and make sure everything is connected correctly.
You can edit the three default messages to say anything you want, and they will appear within the usual mix of messages and graphical effects. If you need to change the number of messages, or the order in which messages and effects appear, the Advanced Topics section below is for you.
Changing the default messages is easy, but changing the number of messages or rearranging the display order is a little bit harder. If you already have a fair amount of Arduino or C programming experience, it will be fairly simple. If not, you will need to pay careful attention not to change anything that could cause errors within the rest of the program.
The messages are stored in strings, which is stored in an array of strings, which is stored in flash memory. Unless specific rules are followed, what seems like a tiny error could make the whole program stop working correctly.
Starting with the default messages.h file below:
// Scrolling messages char string0[] PROGMEM = "macetech.com "; char string1[] PROGMEM = "Your message here... "; char string2[] PROGMEM = "Hello World! "; //char string3[] PROGMEM = " "; const char * stringArray[] PROGMEM = { string0, string1, string2 //string3 };
We can easily add a fourth string, which is present but currently commented out:
// Scrolling messages char string0[] PROGMEM = "macetech.com "; char string1[] PROGMEM = "Your message here... "; char string2[] PROGMEM = "Hello World! "; char string3[] PROGMEM = "HACK THE PLANET "; const char * stringArray[] PROGMEM = { string0, string1, string2, string3 };
We have removed the forward slashes from those lines, and typed a message inside the quote marks. Notice that a comma has been added after string2,
and there is no comma after string3
. This is a comma separated list, and every list item, except the final one, should be followed by a comma.
We can easily extend this to five messages, by adding a fifth string following the same rules:
// Scrolling messages char string0[] PROGMEM = "macetech.com "; char string1[] PROGMEM = "Your message here... "; char string2[] PROGMEM = "Hello World! "; char string3[] PROGMEM = "HACK THE PLANET "; char string4[] PROGMEM = "Go Packers! "; const char * stringArray[] PROGMEM = { string0, string1, string2, string3, string4 };
The default code will not use the fourth and fifth strings we added above. In order to place them into the pattern rotation, we need to edit the main sketch file.
Go back to the first file tab (AS1130Glasses
in the default sketch, will change if you save under a different name) and scroll down to the void loop()
function. It contains a lot of other tasks, but we're mainly concerned with the switch(currentPattern) {
section, copied from the default sketch below:
switch(currentPattern) { case 0: beatingHearts(); break; case 1: scrollMessage(0, SCROLL1X); break; case 2: fire(); break; case 3: scrollMessage(1, SCROLL1X); break; case 4: starField(); break; case 5: sines(); break; case 6: slantBars(); break; case 7: sideRain(0); break; case 8: sparkles(); break; case 9: scrollMessage(2, SCROLL1X); break; case 10: rain(); break; case 11: Plasma(); break; case 12: rider(); break; }
If we look at the following case
statement, this will be run when currentPattern
is equal to 1. Every 10 seconds, currentPattern
will increment by one, until it reaches 13, upon which it will be set back to 0. By placing different functions within different case statements, we can control which patterns appear in order.
case 1: scrollMessage(0, SCROLL1X); break;
The message strings start at 0, so the above case statement will show the first string in messages.h
. If we change it to following, it will run the fifth string in messages.h
.
case 1: scrollMessage(4, SCROLL1X); break;
Without modifying anything else in the code, we can select different strings this way, without having to edit or remove the original three strings. However, if we want to show five different strings, we need to modify the code more.
switch(currentPattern) { case 0: scrollMessage(0, SCROLL1X); break; case 1: scrollMessage(1, SCROLL1X); break; case 2: scrollMessage(2, SCROLL1X); break; case 3: scrollMessage(3, SCROLL1X); break; case 4: scrollMessage(4, SCROLL1X); break; case 5: sines(); break; case 6: slantBars(); break; case 7: sideRain(0); break; case 8: sparkles(); break; case 9: beatingHearts(); break; case 10: rain(); break; case 11: Plasma(); break; case 12: rider(); break; }
The code above has been modified to run all five strings in sequence. They could be arranged in a different order by changing the numbers inside the scrollMessage(0, SCROLL1X);
statements. Changing the order of the case statements will not change the order they are run…if you move the case 12:
section to the top of the list, it will still run last since it is number 12.
The obvious drawback with the above method is that we had to cut out some of the original graphical patterns in order to fit our strings in. It's possible to add more case statements, or just run the first five statements, as shown below.
If you change this line inside void loop()
:
if (currentPattern > 12) currentPattern = 0;
to:
if (currentPattern > 4) currentPattern = 0;
Then only the first five case statements (0 through 4) will be run…in the example above, that means only the five messages will appear. No graphical patterns will be shown.
If you change this line inside void loop()
:
if (currentPattern > 12) currentPattern = 0;
to:
if (currentPattern > 14) currentPattern = 0;
Then two more case
slots are open. We can modify the original switch
section as below:
switch(currentPattern) { case 0: beatingHearts(); break; case 1: scrollMessage(0, SCROLL1X); break; case 2: fire(); break; case 3: scrollMessage(1, SCROLL1X); break; case 4: starField(); break; case 5: sines(); break; case 6: slantBars(); break; case 7: sideRain(0); break; case 8: sparkles(); break; case 9: scrollMessage(2, SCROLL1X); break; case 10: rain(); break; case 11: Plasma(); break; case 12: scrollMessage(3, SCROLL1X); break; case 13: rider(); break; case 14: scrollMessage(4, SCROLL1X); break; }
Now the two added messages have been mixed into the existing sequence of messages and graphical patterns.
In the following code:
case 1: scrollMessage(0, SCROLL1X); break;
The scrollMessage
function is called with the parameter SCROLL1X
. This will display “uncompressed” text; meaning that each pixel of the font is displayed on the LED array in order and maintains the same ratio as the original bitmap font.
If we call the function differently:
case 1: scrollMessage(0, SCROLL2X); break;
The message will be displayed in “compressed” font, meaning the letters will appear squashed to half-width. However, no resolution is lost…it works by displaying alternate columns of the font quickly as the words scroll across the display. The human eye tends to follow the scrolling motion, and persistence-of-vision will effectively double the vertical resolution. This can be useful for displaying long sentences more quickly. It does depend on the observer following the motion of the text with their eyes, so in photographs or if the observer focuses on a single point, the text will appear garbled. We suggest giving it a try and deciding whether compressed or uncompressed display works best for you.