loed dot matrix news ticker

Hi everybody,

Thanks to the well-illustrated example shown at Brainy Bits (https://brainy-bits.com/tutorials/scroll-text-using-the-max7219-led-dot-matrix/) I managed to daisy-chain three MAX7219 8x8 dot led matrix devices and create my own little news ticker. I published the project "News ticker with three MAX7219 8x8 dot led matrix devices" /on my own website:

http://www.zonnepanelen.wouterlood.com/index.php/hobby-elektronica/1345-arduino-news-ticker.
The script is attached (zipped)

So far so good! Tinkering with Arduinos is fun! However, the news ticker runs fixed character strings that are embedded in the script. What I am after is to 'inject' character strings via the Serial Montor or from a second Arduino that is connected iwth the news ticker-Arduino via e.g. an l2C master-slave configuration. I am quite new in this field, and I am just a hobbyist, not a native programmer. I welcome suggestions on how to achieve this type of communication. the result would be that from my computer I should be able to change the text on the news ticker whil the news ticker is running.
Thanks a lot in advance - Floris

max7219_dot_matrix_news_ticker_ino.zip (2.05 KB)

It might be as simple as attached but I have not tried compiling of running it.

//dot matrix news ticker
//acknowledgemets Brainy-bits
//https://brainy-bits.com/tutorials/scroll-text-using-the-max7219-led-dot-matrix/

#include <MaxMatrix.h>
#include <avr/pgmspace.h>


PROGMEM const unsigned char CH[] = {
3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space
1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // !
3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // "
5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, // #
4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $
5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // %
5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // &
1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // '
3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // (
3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // )
5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, // *
5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // +
2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // ,
4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, // -
2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // .
4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // /
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0
3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1
4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2
4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3
4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4
4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5
4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6
4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7
4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8
4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9
2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // :
2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, // ;
3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // <
3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // =
3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // >
4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ?
5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @
4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, // A
4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B
4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C
4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D
4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E
4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F
4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G
4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H
3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I
4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J
4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K
4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L
5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M
5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // O
4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P
4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q
4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R
4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S
5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, // T
4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U
5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V
5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W
5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X
5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y
4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z
2, 8, B01111111, B01000001, B00000000, B00000000, B00000000, // [
4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash
2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ]
3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat
4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _
2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // `
4, 8, B00100000, B01010100, B01010100, B01111000, B00000000, // a
4, 8, B01111111, B01000100, B01000100, B00111000, B00000000, // b
4, 8, B00111000, B01000100, B01000100, B00101000, B00000000, // c
4, 8, B00111000, B01000100, B01000100, B01111111, B00000000, // d
4, 8, B00111000, B01010100, B01010100, B00011000, B00000000, // e
3, 8, B00000100, B01111110, B00000101, B00000000, B00000000, // f
4, 8, B10011000, B10100100, B10100100, B01111000, B00000000, // g
4, 8, B01111111, B00000100, B00000100, B01111000, B00000000, // h
3, 8, B01000100, B01111101, B01000000, B00000000, B00000000, // i
4, 8, B01000000, B10000000, B10000100, B01111101, B00000000, // j
4, 8, B01111111, B00010000, B00101000, B01000100, B00000000, // k
3, 8, B01000001, B01111111, B01000000, B00000000, B00000000, // l
5, 8, B01111100, B00000100, B01111100, B00000100, B01111000, // m
4, 8, B01111100, B00000100, B00000100, B01111000, B00000000, // n
4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o
4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p
4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q
4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r
4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s
3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t
4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u
5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, // v
5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w
5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x
4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y
3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z
3, 8, B00001000, B00110110, B01000001, B00000000, B00000000, // {
1, 8, B01111111, B00000000, B00000000, B00000000, B00000000, // |
3, 8, B01000001, B00110110, B00001000, B00000000, B00000000, // }
4, 8, B00001000, B00000100, B00001000, B00000100, B00000000, // ~
};

int data  = 12;    // DIN pin of MAX7219 module
int load  = 10;    // CS  pin of MAX7219 module
int clock = 11;    // CLK pin of MAX7219 module

int maxInUse = 3;  //how many MAX7219 are connected

MaxMatrix m(data, load, clock, maxInUse); // define Library

byte buffer[10];

char serialString[200];


void setup(){
  Serial.begin(9600);
  m.init(); // module MAX7219
  m.setIntensity(5); // LED Intensity 0-15
}

void loop(){
  m.shiftLeft(false, true);
  delay(100);
  Serial.readBytesUntil("\n", serialString, sizeof(serialString) - 1);
  
  printStringWithShift(serialString, 100);  // Send scrolling Text
}

// Put extracted character on Display
void printCharWithShift(char c, int shift_speed){
  if (c < 32) return;
  c -= 32;
  memcpy_P(buffer, CH + 7*c, 7);
  m.writeSprite(maxInUse*8, 0, buffer);
  m.setColumn(maxInUse*8 + buffer[0], 0);
  
  for (int i=0; i<buffer[0]+1; i++) 
  {
    delay(shift_speed);
    m.shiftLeft(false, false);
  }
}

// Extract characters from Scrolling text
void printStringWithShift(char* s, int shift_speed){
  while (*s != 0){
    printCharWithShift(*s, shift_speed);
    s++;
  }
}

Here's a suggestion for you, and something to challenge you to improve your coding skills.

If you use an ESP chip-based module, such as a Wemos D1 Mini (my current favourite), you could get it to connect to WiFi and read actual news feeds from the internet and display them. The Wemos replaces the Arduino too, and drives the display directly. You can almost certainly run your current sketch on it, too.

Paul

Riva:
It might be as simple as attached but I have not tried compiling of running it.

//dot matrix news ticker

...

PROGMEM const unsigned char CH[] = {
...
4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $
...

Can you explain what the 4 and 8 represent?

ieee488:
Can you explain what the 4 and 8 represent?

They are the width and height of the character in bits/pixels/leds.

PaulRB:
They are the width and height of the character in bits/pixels/leds.

Then why is

1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // !

but

2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // :

Is it a typo?

Also, it seems that the height is always 8. So why do you need set it for every character?

Maybe; dunno.

@Riva: Thanks! I'm going to experiment with this script

1ee488: the '4,8' refers to the 8x8 led dot matrix. 4 means that the character occupies 4 columns, 8 means that one column is 8 leds high. The funny thing is that there is no characters in this set that is higher than 7 dots.

All the other commenters: thanks a lot for sharing your expertise. This is a wonderful forum.

photoncatcher:
@Riva: Thanks! I'm going to experiment with this script

1ee488: the '4,8' refers to the 8x8 led dot matrix. 4 means that the character occupies 4 columns, 8 means that one column is 8 leds high. The funny thing is that there is no characters in this set that is higher than 7 dots.

Most fonts are 5x7.

And there is a typo for those two characters that I posted about. Not sure if there are others.

it seems it is not with the actual IDE compatible.. or i am to dump

invalid conversion from 'const char*' to 'char' [-fpermissive]

Look at this Parola project.
http://forum.arduino.cc/index.php?topic=171056.0
And what is possible.

A block of four is now $6 shipped on ebay.
http://www.ebay.com/itm/MAX7219-dot-matrix-module-Arduino-microcontroller-module-4-in-one-display-/171578345542?hash=item27f2ddc846:g:tssAAOSwkNZUiYkT
Leo..

nicepix4u:
it seems it is not with the actual IDE compatible.. or i am to dump

invalid conversion from 'const char*' to 'char' [-fpermissive]

Sound like the code has not been updated to work with the latest IDE/compiler syntax needed for PROGMEM stuff.
It will probably compile fine using the older 1.0.6 IDE.