use the parola library in my project

Hello dear Forummembers,

Here’s a question for you. hopefully somebody can point me in the right direction.

I am stil working on my pinbal machine. As a newby I messed around a lot but after a lot of experimenting I got things working… Yeahh!!. :slight_smile: I have got a master slave setup. The master collects the inputs from the switches and controls the output to the lights, it also controls the music and some things more. It sends bytes to the slave. The slave has to calculate the points (still very simple, but i have to start somewhere). On my computer I open the serial monitor and it works like a charme.

So now I would like to display the points on my home made matrix. This Matrix works with max 7219 ics (6 of them). The display works thanks to the Parola librarys. Awsome!. even the Sprites look cool.

Here is my problem and the question. For the points (score) I use an unsigned long andc with Serial.print, it prints the score on my Serialmonitor but not on my display. So I have tryed a lot of things, but I could not jet figure out how to do it. Also I have read that I should transform the unsigned long into a string. (%lu. d) but again I dont really know how to do that. I have look around on the internet, in my books and I guess I will figure it out some time.
But if somebody wants to give me a Hint or a clue on how to to do this I would apprieciate it a lot of coarse.
(sorry for my bad English. Not my native language, but I try )

here is the code I have made sofar. I use multiple tabs so it is more readable. That is why there are three pieces.

Main… varialbes, setup and loop

[code]
#include <Wire.h>
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include <MD_UISwitch.h>


/********************
***** DISPLAY *******
********************/

#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 6
#define CLK_PIN   13  //  SCK   (clock pin)
#define DATA_PIN  11  //  MOSI  (din pin, data in)
#define CS_PIN    10  //  SS    (load pin)

MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

/********************
*****  DATA  ********
********************/

unsigned long Punten = 0;
int StrafPunten = 0;
int BonusPunten = 0;
int Score = 0;
int i = 0; 
int Start = 0;

/********************
*****  TIMER  *******
********************/

int periode = 2500;             // Timer variabele
int flash = 100;
unsigned long time_now = 0;
unsigned long time_flash = 0;

/********************
*****  SET UP  ******
********************/

void setup(){
  
  Wire.begin(8);               
  Wire.onReceive(receiveEvent);
  Serial.begin(9600);
  P.begin();
}


/********************
******  LOOP  *******
********************/


void loop() {
  

}

[/code]

Hopefully You can give me an advice, direction, hint.
Thanks, Don van Raak.

here are the second and third piece. (it was to long to post al at once)

Data. bytes come from the master. Then an unsigned long starts at o points and points are added or even subtracked. Via Serial .print this can be read on the Serialmonitor. As I see in the Parola test example. P.print should print it on the matrix display.
But no it did not.

[code]
/* DATA die binnenkomt van de master Arduino 
Deze wordt omgezet naar de punten en vervolgens via display getoont
*/

void receiveEvent(int) {

    while (1 < Wire.available()) { 
    char c = Wire.read(); 
    Serial.print(c);        

  }
    
    int Score = Wire.read() ;
    int i = (Score);

  
    
        switch (i) {

        case 10:
          if ((i = 10) && (Start >= 1)) {                        // Normale Score = 10
         
          Punten = Punten +100;
          Serial.print ( " Score is " );
          Serial.println ( Punten );
          P.print (Punten);
          TimerPeriode();
  }
  break;
  
     case 15:
     
      if ((i = 15) && (Start >= 1)) {                   // Normale Score = 15
          
          Punten = Punten + 200;
          Serial.print ( " Score is " );
          Serial.println ( Punten );
          P.print (Punten);
          TimerPeriode();
  }
  break;
 
     case 20:
     
      if ((i = 20) && (Start >= 1)) {                   // Normale Score = 20
          
          Punten = Punten + 300;
          Serial.print ( " Score is " );
          Serial.println (Punten); 
          P.print (Punten);
          TimerPeriode();
  }
  break;
  
     case 25:
     
      if ((i = 25) && (Start >= 1)) {                   // Normale Score = 25
          
          Punten = Punten + 400;
          Serial.print ( " Score is " );
          Serial.println (Punten);
          P.print (Punten);
          TimerPeriode();
  }
  break;
     case 30:
     
      if ((i = 30) && (Start >= 1)) {                   // Normale Score = 30
          
          Punten = Punten + 500;
          Serial.print ( " Score is " );
          Serial.println (Punten);
          P.print (Punten);
          TimerPeriode();
  }
  break;
  
     case 35:
     
      if ((i = 35) && (Start >= 1)) {                   // Straf Score = 35
          StrafPunten = 200;
          Serial.print ( " Dit kost je punten " );
          Serial.println (StrafPunten);
          P.print ( " STRAFPUNT " );
          TimerPeriode();
          P.print (StrafPunten);
          TimerPeriode();
          StrafPunten = 0;
          Punten = Punten - 200;
          Serial.print ( " Score is " );
          Serial.println (Punten);
          P.print (Punten);
          TimerPeriode();
  }
  break;
  
     case 40:
     
      if ((i = 40) && (Start >= 1)) {                   // Straf Score = 40
          StrafPunten = 300;
          Serial.print ( " HELAAS " );
          Serial.println (StrafPunten);
          P.print ( " HELAAS " );
          TimerPeriode();
          P.print (StrafPunten);
          TimerPeriode();
          StrafPunten = 0;
          Punten = Punten - 300;
          Serial.print ( " Score is " );
          Serial.println (Punten);
          P.print (Punten);
          TimerPeriode();
  }
  break;
  
     case 45:
     
      if ((i = 45) && (Start >= 1)) {                   // Straf Score = 45
          StrafPunten = 400;
          Serial.print ( " WAAROM " );
          Serial.println (StrafPunten);
          P.print ( " WAAROM ? " );
          TimerPeriode();
          P.print (StrafPunten);
          TimerPeriode();
          StrafPunten = 0;
          Punten = Punten - 400;
          Serial.print ( " Score is " );
          Serial.println (Punten);
          P.print (Punten);
          TimerPeriode();
  }
  break;
  
     case 50:
     
      if ((i = 50) && (Start >= 1)) {                   // Bonus Score = 50
          BonusPunten = 5000;
          Serial.print ( " Bonus " );
          Serial.println (BonusPunten);
          P.print ( " BONUS " );
          TimerPeriode();
          P.print (BonusPunten);
          TimerPeriode();
          Punten = Punten + 5000;
          BonusPunten = 0;
          Serial.print ( " Score is " );
          Serial.println (Punten);
          P.print (Punten);
          TimerPeriode();
  }
  break;
  
     case 55:
     
      if ((i = 55) && (Start >= 1)) {                   // Bonus Score = 55
          BonusPunten = 10000;
          Serial.print ( " GEWELDIG " );
          Serial.println (BonusPunten);
          P.print ( " GEWELDIG " );
          TimerPeriode();
          P.print (BonusPunten);
          TimerPeriode();
          BonusPunten = 0;
          Punten = Punten + 10000;
          Serial.print ( " Score is " );
          Serial.println (Punten);
          P.print (Punten);
          TimerPeriode();
  }
  break;
  
     case 60:
     
      if ((i = 60) && (Start >= 1)) {                   // Bonus Score = 60
          BonusPunten = 50000;
          Serial.print ( " SUPER " );
          Serial.println (BonusPunten);
          P.print ( " SUPER " );
          TimerPeriode();
          P.print (BonusPunten);
          TimerPeriode();
          BonusPunten = 0;
          Punten = Punten + 50000;
          Serial.print ( " Score is " );
          Serial.println (Punten);
          P.print (Punten);
          TimerPeriode();
  }
  break;
  
     case 65:
     
      if ((i = 65) && (Start >= 1)) {                   // Bonus Score = 65
          BonusPunten = 100000;
          Serial.print ( " MEGA BONUS " );
          Serial.println (BonusPunten);
          P.print ( " MEGA BONUS " );
          TimerPeriode();
          P.print (BonusPunten);
          TimerPeriode();
          BonusPunten = 0;
          Punten = Punten + 100000;
          Serial.print ( " Score is " );
          Serial.println (Punten);
          P.print (Punten);
          TimerPeriode();
  }
  break;
  
     case 70:
     
      if (i = 70) {                                     // Start  
          Start ++;
          Serial.print ( " Start " );
          Serial.println ( Start );
          Serial.print ( " Score is " );
          Serial.println (Punten);
          P.print ( " START " );
          TimerPeriode();
          P.print (Punten);
          TimerPeriode();
  }
  break;
      }
    }

[/code]

Delay with Millis function.

[code]
/* *********************
*******  MILLIS  *******
********************* */

void TimerPeriode() {

  time_now = millis();

  while (millis() < time_now + periode) {

    //wacht ongeveer [periode] ms (3 SECONDE)
  }
}
  void TimerFlash(){
    
  
  time_flash = millis();

  while (millis() < time_flash + flash){
    
    //wacht ongeveer [flash] ms (0,1 SECONDE)
  }
  }

[/code]

here is a picture of my matrix