Printing 2d Array on Max7219 LED matrix

Hello there,

plz forgive me its my first post. So I have this in my eyes wierd issue with a Max7219 Matrix. I want to a print my array called Screen on this matrix so i can move a single pixel via a joystick. The problem that spinns my head crazy is that it only shows the first row of the array on the matrix. The part of my code plotting the array on the matrix is called 'plot'.

I am using an arduino Uno, a max7219 LED matrix and a joystick module.

Since I am not a foreign english speaker I dont realy know how to explain my problem better. Hopefully its understandebal. So if you have a question understanding my problem I will give my best to answer it. :sweat_smile:

Thank you.
Alec

#include "LedControl.h"
#include "MAX7219_8x8_matrix.h"
#define joystickX A0
#define joystickY A1

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

unsigned long delaytime=500;
unsigned long Pause=3000;
long int Time=0;
const int jTast = 2;
int TasterStatus = LOW;
int SpielStatus = 0;

/* Anschluss der Matrix
 * pin 12 = DataIn
 * pin 11 = CLK
 * pin 10 = CS
 */

byte Screen[8][8] = {

    {0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0}, 
    {0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0}
  };

void setup() {

  Serial.begin(9600);
  lc.shutdown(0,false);
  lc.setIntensity(0,8);
  lc.clearDisplay(0);
  pinMode(jTast, INPUT_PULLUP);

  digitalWrite(TasterStatus, LOW);
  
}

void on(){

    TasterStatus =!digitalRead(jTast);

    if (TasterStatus == HIGH) {
        Screen[3][4] = 1;
        SpielStatus = 1;
        Serial.println("Wird angeschalten");
        delay(Pause);
    }
};

void off(){

  TasterStatus =!digitalRead(jTast);

  if(TasterStatus == HIGH){
      SpielStatus = 0 ; 
      memset(Screen, 0, sizeof(Screen));
      Serial.println("Wird ausgeschalten");
      delay(Pause);
  }
};


void walk(){

  int x = analogRead(joystickX);
  int y = analogRead(joystickY);

//i = Spalte
//j = Zeile

  if(y <= 200){
    //move right
    for (int i=0; i<8; i++){
      for (int j=0; j<8; j++){
        if(Screen[i][j] == 1){
          if(j+1 > 7){
            Screen[i][j] = 1;
          }
          else{
          Screen[i][j] = 0;
          Screen[i][j+1] = 1;
          break;
          }
        }
      }
    }
  }
  if(y >= 800){
    //move left
    for (int i=0; i<8; i++){
      for (int j=0; j<8; j++){
        if(Screen[i][j] == 1){
          if(j-1 < 0){
            Screen[i][j] = 1;
          }
          else{
          Screen[i][j] = 0;
          Screen[i][j-1] = 1;
          }
        }
      }
    }
  }
  if(x >= 800){
    //move down
    for (int j=0; j<8; j++){
      for (int i=0; i<8; i++){
        if(Screen[i][j] == 1){
          if(i+1 > 7){
            Screen[i][j] = 1;
          }
          else{
          Screen[i][j] = 0;
          Screen[i+1][j] = 1;
          break;
          }
        }
      }
    }
  }
  if(x <= 200){
    //move up
    for (int i=0; i<8; i++){
      for (int j=0; j<8; j++){
        if(Screen[i][j] == 1){
          if(i-1 < 0){
            Screen[i][j] = 1;
          }
          else{
          Screen[i][j] = 0;
          Screen[i-1][j] = 1;
          }
        }
      }
    }
  }
}
void plot(){
    for (int i=0; i<8; i++){
      for (int j=0; j<8; j++){
        lc.setRow(i,j,Screen[i][j]);
      }
    }
}
void auszeit(){
  
  if(millis() > delaytime + Time){
    Time = millis();
  }
  
}

void loop(){
  
  if(SpielStatus == 0){
    on();
    
  }
  if(SpielStatus == 1){
    off();
    
  }
  walk();
  plot();
  
    for (int i=0; i<8; i++){
      for (int j=0; j<8; j++){
        Serial.print(Screen[i][j]);
      }
    }
    Serial.print(" TastenStatus: ");
    Serial.print(TasterStatus);
    Serial.print(" SpielStatus: ");
    Serial.println(SpielStatus);
  

    
    
}

The max7219_8x8_matrix.h I am using:

/***************************************************
** 						  **
**  Max7219 LED Matrix library for Arduino   	  **
** 						  **
**  Downloaded from:				  **
**  www.arduino-projekte.de			  **
**						  **
***************************************************/

#ifndef MAX7219_8x8_matrix_h
#define MAX7219_8x8_matrix_h

//#include <inttypes.h>
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

class Sprite;

class MAX7219_8x8_matrix
{
  private:

    uint8_t _pinData;
    uint8_t _pinClock;
    uint8_t _pinLoad;

//    uint8_t* _buffer;
    bool _BUFFER[8][8];
    uint8_t _screens;
    uint8_t _maximumX;
    uint8_t _arraydata[8][8];

    void clock();    
    void send_data(uint8_t data);
    void send_data_array(bool data[8]);
    void setRegister(uint8_t, uint8_t);
    void refresh_row(uint8_t);
    void setScanLimit(uint8_t);
   // void buffer(uint8_t, uint8_t, bool);
    uint8_t convert_data(bool data[8]);



  public:

    MAX7219_8x8_matrix(uint8_t DIN, uint8_t CS, uint8_t CLK);
    void setBrightness(uint8_t value);
    void set_pixel(uint8_t x, uint8_t y, bool value);
    void set_pixel_orbital(uint8_t x, bool value);
    void invert_pixel(uint8_t x, uint8_t y);
    void set_row(uint8_t y, uint8_t value);
    void set_col(uint8_t x, uint8_t value);
    void matrix(bool a[8][8]);
    void matrix(uint8_t a[8]);
    void invert_matrix(void);
    void set_char(uint8_t CHAR);
    void mask(uint8_t mask[8], bool value);
    void square(uint8_t size, bool value);
    void clear(void);
    void fill(void);
    void rotate_matrix_cw();
    void rotate_matrix_ccw();

};

#endif

please add also the

MAX7219_8x8_matrix.h or link where you have got it from

PS: if you prefer to discuss in German, report your sketch to the moderators and kindly ask them to move it to the German section.

The MAX7219_8x8_matrix.h is a fragment of some old code I created days ago. This lib seamed usefull to me with my issue so implemented it but i am not using it in the code at moment. Sorry for the confusion. The lib could be used to to solve my problem but i dont know how to implement it.