Unable to make dynamic scrolling arrows on MAX7219

Hello world!
I'm a newbie and try to setup a tool to display a distance difference on a Led matrix display MAX7219 (4 modules), I want to use it to enter with the car in a narrow garage.
The 2 central modules are used to show the difference and the external modules are used to show an arrow (right or left) to suggest where to go and when diff= 0 both should show two up-arrows.
I adapted the examples included in the MD_MAX72XX library to create my program.
It works almost fine except the scrolling function: the "side arrows" are displayed but it scroll only the middle row (I get an horizontal line "scrolling" on the interested module).
When diff = 0, I do not have the up-arrows at all.
here is the code:

// Program to display analog read and animate arrow:
// two central modules to display the reading
// If > 10 then arrow left scroll on right module
// if < -10 then arrow right scroll on left module
// if between -9 and 9 then arrows up on both external module


#include <MD_MAX72xx.h>
#include <SPI.h>

// We always wait a bit between updates of the display
#define  DELAYTIME  300  // in milliseconds

// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES  4

#define CLK_PIN   13  // or SCK
#define DATA_PIN  11  // or MOSI
#define CS_PIN    10  // or SS


// SPI hardware interface
MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);


// Global variables
uint32_t  lastTime = 0;
int diff = 0 ;
int diffcent = 0 ;


void setup() {
 pinMode(A0, INPUT);
 mx.begin();

  Serial.begin(9600);
  
  // use wraparound mode
  mx.control(0,3,MD_MAX72XX::WRAPAROUND, MD_MAX72XX::ON);
  mx.clear();
  
  lastTime = millis();

  mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON); 
}
void showCharset(void) {

  mx.clear(1,2);
  mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);
     
      char hex[3];

      sprintf(hex, "%02d", abs(diffcent));

      mx.clear(1);
      mx.setChar((2*COL_SIZE)-2,hex[1]);
      mx.clear(2);
      mx.setChar((3*COL_SIZE)-3,hex[0]);
   
  
  mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
 }

void runArrows(void)
{
 if (diffcent > 10 ) {
	mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);    
	mx.setChar(28, 27);
    mx.transform(3,3,MD_MAX72XX::TSL);
    mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
	mx.clear(0,0);
  }
    
 else if (diffcent < -10) {
    mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);
    mx.setChar(7, 26);
    mx.transform(0,0,MD_MAX72XX::TSR);
    mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
	mx.clear(3,3);
    }
 else {
   

      mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);
      mx.setChar (7, ArrowUp);
      mx.setChar (28, ArrowUp);
      mx.transform(3,3,MD_MAX72XX::TSU);
      mx.transform(0,0,MD_MAX72XX::TSU);
      mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
      //mx.update();
      }   
}

void loop() {
 int diff =analogRead(A0);
 diffcent = diff - 500 ; 
  Serial.println(diffcent);
  if (millis() - lastTime >= DELAYTIME)
  {
  showCharset();
  newArrows();
  lastTime = millis();
  } 
}

I tried to use MD.Parola, but I was able to display only "right arrow" (26), when select other "arrows", I got blank display.
Also, because I'm using Adafruit_VL53L0X for distance measurement, it seems to me that all the libraries and the program are too big to be hosted in Arduino Uno.

Please, could you give me help ?
Probably, I have to change the way on how to load the character (arrows) to be displayed ..... I tried in different ways, but I lack of experience on how to use buffers or arrays or....
Thanks in advance for your attention and patience.
(let me know if this post is in a wrong place.....)
Maurizio.

Can you post a video of what the display is doing? This would be easier to understand than the description.

Also, you can reduce the size of the Parola library by turning off the animations you don't use (see this article https://arduinoplusplus.wordpress.com/2018/09/23/parola-a-to-z-optimizing-flash-memory/).

The code you posted does not compile.
There are function call and variable errors.

sketch.ino: In function 'void runArrows()':
sketch.ino:88:22: error: 'ArrowUp' was not declared in this scope
       mx.setChar (7, ArrowUp);
                      ^~~~~~~
sketch.ino: In function 'void loop()':
sketch.ino:104:3: error: 'newArrows' was not declared in this scope
   newArrows();
   ^~~~~~~~~
sketch.ino:104:3: note: suggested alternative: 'runArrows'
   newArrows();
   ^~~~~~~~~
   runArrows

Error during build: exit status 1

Also post your project schematic.

I have to repost the code, because I uploaded not the "last one" tested:

the "ArrowUp" was not declared, i substituted with "24" (code for ArrowUp in the font.cpp)

// Program to exercise the MD_MAX72XX library
//
// Test the library transformation functions

#include <MD_MAX72xx.h>
#include <SPI.h>

// We always wait a bit between updates of the display
#define  DELAYTIME  300  // in milliseconds

// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES  4

#define CLK_PIN   13  // or SCK
#define DATA_PIN  11  // or MOSI
#define CS_PIN    10  // or SS


// SPI hardware interface
MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// Arbitrary pins
//MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

// Global variables
uint32_t  lastTime = 0;
int diff = 0 ;
int diffcent = 0 ;

void setup() {
 pinMode(A0, INPUT);
 mx.begin();

  Serial.begin(115200);
  /*
  // use wraparound mode
  mx.control(0,3,MD_MAX72XX::WRAPAROUND, MD_MAX72XX::ON);
  mx.clear();
  //mx.setChar(7, 26);
  //mx.setChar(28, 27);

  
  if (diff > 3) {
  mx.setChar(28, 27);
  }
  else if (diff < -3){
  mx.setChar(7,26);
  }
  else { 
  mx.setChar (7, 24);
  mx.setChar (29, 24);
  }
  */
  lastTime = millis();

  mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON); 
}
void showCharset(void) {

  mx.clear(1,2);
  mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);
  //mx.update(MD_MAX72XX::OFF);

    
      char hex[3];

      sprintf(hex, "%02d", abs(diffcent));

      mx.clear(1);
      mx.setChar((2*COL_SIZE)-2,hex[1]);
      mx.clear(2);
      mx.setChar((3*COL_SIZE)-3,hex[0]);
   
    //mx.update();
  //  delay(DELAYTIME*2);
  
  mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
  //mx.update(MD_MAX72XX::ON);
}

void runArrows(void)
{
if (diffcent > 10 ) {
    mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);
    mx.setChar(28, 27);
    mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
    mx.transform(3,3,MD_MAX72XX::TSL);
    mx.clear(0,0);
    }
 else if (diffcent < -10) {
    mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);
    mx.setChar(7, 26);
    mx.transform(0,0,MD_MAX72XX::TSR);
    mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
    mx.clear(3,3);
    }
 else {
           mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);
      mx.setChar (7, 24);
      mx.setChar (29, 24);
      mx.transform(3,3,MD_MAX72XX::TSU);
      mx.transform(0,0,MD_MAX72XX::TSU);
      mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
      //mx.update();
      }   
}

void loop() {
 int diff =analogRead(A0);
 diffcent = diff - 500 ; 
 Serial.println(diffcent);
  if (millis() - lastTime >= DELAYTIME)
  {
  showCharset();
  runArrows();
  //delay(200);
  lastTime = millis();
  } 
}

I also have the video, but I don't know how to upload it.
Thanks, Maurizio

here is the project drawing (I'm using wokwi)

Post your project Wokwi Link.

ruilviana, here is the link:

Thanks for your time.
Maurizio

For me look like :
image
What is the problem?

I'd like to have both arrows scolling up, and when the difference is more than 10, the related lateral arrow should scroll toward the outside of the display panel.

Try this code:

That's what I wanted!!! :ok_hand:
Thank you!
Now, I'm going to study the "characters" part and understand it, it seems that Arrow Up (ASCII24) cannot be used.
As far as I get, the transform with "TransformType"alone was not the right method,
but the trick was to use setChar or setRow with incremental loop.

Again, thank you!
Maurizio :laughing: