Problemas con matriz de led y libreria

Hola amigos, se esta haciendo una matriz de led con arduino uno, max7219 y matriz de led, busque en san google y encontre varias modelos de los cuales use uno, la libreria la descargue desde internet, el problema es que no me deja compilarlo

Nota, puse serial prin para ver en monitor virtual los pasos realizados por el arduino

adjunto programa y archivo

Espero me puedan ayudar donde esta el error

Juka

LedControl.zip (564 KB)

por error no adjunte el programa

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

const int numDevices = 1;      // number de MAX7219s usedo
const long scrollDelay = 90;   // ajuste velocidad de scrolling 

unsigned long bufferLong [14] = {0}; 

LedControl lc=LedControl(12,11,10,numDevices); // DIN 12, CS 10, CLK 11


prog_uchar scrollText[] PROGMEM ={
    "texto a visualizar "};

void setup(){
  Serial.begin(9600);
  Serial.print("empieza el programa");// solo para visualizar en monitor serial
    for (int x=0; x<numDevices; x++){
        lc.shutdown(x,false);       //The MAX72XX is in power-saving mode on startup
        lc.setIntensity(x,1);       // Set the brightness to default value
        lc.clearDisplay(x);         // and clear the display
        Serial.println("cierra el setup");// solo para visualizar en monitor serial
    }
}

void loop(){ 
  Serial.println("empieza el texto");// solo para visualizar en monitor serial
  
    scrollMessage(scrollText);
Serial.println("cierra texto");// solo para visualizar en minitor serial
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

prog_uchar font5x7 [] PROGMEM = {      //Numeric Font Matrix (Arranged as 7x font data + 1x kerning data)
    B00000000, //Space (Char 0x20)
    B00000000,
    B00000000,
    B00000000,
    B00000000,
    B00000000,
    B00000000,
    6,

};



// Scroll Message
void scrollMessage(prog_uchar * messageString) {
    int counter = 0;
    int myChar=0;
    do {
        // read back a char 
        myChar =  pgm_read_byte_near(messageString + counter); 
        if (myChar != 0){
            loadBufferLong(myChar);
        }
        counter++;
    } 
    while (myChar != 0);
}
// Load character into scroll buffer
void loadBufferLong(int ascii){
    if (ascii >= 0x20 && ascii <=0x7f){
        for (int a=0;a<7;a++){                      // Loop 7 times for a 5x7 font
            unsigned long c = pgm_read_byte_near(font5x7 + ((ascii - 0x20) * 8) + a);     // Index into character table to get row data
            unsigned long x = bufferLong [a*2];     // Load current scroll buffer
            x = x | c;                              // OR the new character onto end of current
            bufferLong [a*2] = x;                   // Store in buffer
        }
        byte count = pgm_read_byte_near(font5x7 +((ascii - 0x20) * 8) + 7);     // Index into character table for kerning data
        for (byte x=0; x<count;x++){
            rotateBufferLong();
            printBufferLong();
            delay(scrollDelay);
        }
    }
}
// Rotate the buffer
void rotateBufferLong(){
    for (int a=0;a<7;a++){                      // Loop 7 times for a 5x7 font
        unsigned long x = bufferLong [a*2];     // Get low buffer entry
        byte b = bitRead(x,31);                 // Copy high order bit that gets lost in rotation
        x = x<<1;                               // Rotate left one bit
        bufferLong [a*2] = x;                   // Store new low buffer
        x = bufferLong [a*2+1];                 // Get high buffer entry
        x = x<<1;                               // Rotate left one bit
        bitWrite(x,0,b);                        // Store saved bit
        bufferLong [a*2+1] = x;                 // Store new high buffer
    }
}  
// Display Buffer on LED matrix
void printBufferLong(){
  for (int a=0;a<7;a++){                    // Loop 7 times for a 5x7 font
    unsigned long x = bufferLong [a*2+1];   // Get high buffer entry
    byte y = x;                             // Mask off first character
    lc.setRow(3,a,y);                       // Send row to relevent MAX7219 chip
    x = bufferLong [a*2];                   // Get low buffer entry
    y = (x>>24);                            // Mask off second character
    lc.setRow(2,a,y);                       // Send row to relevent MAX7219 chip
    y = (x>>16);                            // Mask off third character
    lc.setRow(1,a,y);                       // Send row to relevent MAX7219 chip
    y = (x>>8);                             // Mask off forth character
    lc.setRow(0,a,y);                       // Send row to relevent MAX7219 chip
  }
}

OK
Casualmente hoy me llegaron las matrices de leds que pedi a China, 45 dias pero llegaron.

Y segui este Tutorial y me funciono.

Hay que actualizar el codigo, donde coloca

PROGMEM prog_uchar CH[]

Por

const char CH[] PROGMEM=

La mejor librería para mi gusto es del Sr. Gammon (moderador global del ARduino)

Aca un enlace muy descriptivo

Saludos Surbyte creo que me quedo con la que publique, se que es cosa de gustos, pero me permite mas esta libreria.

Y la modifique para usarla con SPI

Hola, he armado la matriz y lo que me da es lo que esta en las fotos ( no pude subir un video), adjunto programa para sus comentarios, no se lo que pueda ser, los led prendes todos en algun momento, debo indicar que la matriz es la 1088as y en todo los tutoriales que he visto es la 1088ah, puede ser eso????

Espero me puedan ayudar

Juka

subí el vídeo a youtube, adjunto link para que lo puedan ver

juka

PD, de ser posible si alguien ya tiene el hadware instalado prueba el programa, a lo mejor el problema es de hadware y no de programacion

Disculpas, pero o subi el programa aqui va

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

const int numDevices = 2;      // number of MAX7219s used
const long scrollDelay = 100;   // adjust scrolling speed

unsigned long bufferLong [14] = {0}; 

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

prog_uchar scrollText[] PROGMEM ={
    "  Hola, se desplaza BIEN \0"};

void setup(){
    for (int x=0; x<numDevices; x++){
        lc.shutdown(x,false);       //The MAX72XX is in power-saving mode on startup
        lc.setIntensity(x,8);       // Set the brightness to default value
        lc.clearDisplay(x);         // and clear the display
    }
}

void loop(){ 
  Serial.begin(9600);
  Serial.println("empieza el programa");// solo para visualizar en monitor serial

  scrollMessage(scrollText);
  Serial.println("setup");// solo para visualizar en monitor serial
    scrollFont();
 Serial.println("cierra el setup");// solo para visualizar en monitor serial

}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

prog_uchar font5x7 [] PROGMEM = {      //Numeric Font Matrix (Arranged as 7x font data + 1x kerning data)
    B00000000,	//Space (Char 0x20)
    B00000000,
    B00000000,
    B00000000,
    B00000000,
    B00000000,
    B00000000,
    6,

    B10000000,	//!
    B10000000,
    B10000000,
    B10000000,
    B00000000,
    B00000000,
    B10000000,
    2,

};

void scrollFont() {
  Serial.println("scroll");
    for (int counter=0x20;counter<0x80;counter++){
        loadBufferLong(counter);
        delay(500);
    }
}

// Scroll Message
void scrollMessage(prog_uchar * messageString) {
  Serial.println("mensaje");
    int counter = 0;
    int myChar=0;
    do {
        // read back a char 
        myChar =  pgm_read_byte_near(messageString + counter); 
        if (myChar != 0){
            loadBufferLong(myChar);
        }
        counter++;
    } 
    while (myChar != 0);
}
// Load character into scroll buffer
void loadBufferLong(int ascii){
  Serial.println("load");
    if (ascii >= 0x20 && ascii <=0x7f){
        for (int a=0;a<7;a++){                      // Loop 7 times for a 5x7 font
            unsigned long c = pgm_read_byte_near(font5x7 + ((ascii - 0x20) * 8) + a);     // Index into character table to get row data
            unsigned long x = bufferLong [a*2];     // Load current scroll buffer
            x = x | c;                              // OR the new character onto end of current
            bufferLong [a*2] = x;                   // Store in buffer
        }
        byte count = pgm_read_byte_near(font5x7 +((ascii - 0x20) * 8) + 7);     // Index into character table for kerning data
        for (byte x=0; x<count;x++){
            rotateBufferLong();
            printBufferLong();
            delay(scrollDelay);
        }
    }
}
// Rotate the buffer
void rotateBufferLong(){
  Serial.println("rotacion");
    for (int a=0;a<7;a++){                      // Loop 7 times for a 5x7 font
        unsigned long x = bufferLong [a*2];     // Get low buffer entry
        byte b = bitRead(x,31);                 // Copy high order bit that gets lost in rotation
        x = x<<1;                               // Rotate left one bit
        bufferLong [a*2] = x;                   // Store new low buffer
        x = bufferLong [a*2+1];                 // Get high buffer entry
        x = x<<1;                               // Rotate left one bit
        bitWrite(x,0,b);                        // Store saved bit
        bufferLong [a*2+1] = x;                 // Store new high buffer
    }
}  
// Display Buffer on LED matrix
void printBufferLong(){
  Serial.println("print");
  for (int a=0;a<7;a++){                    // Loop 7 times for a 5x7 font
    unsigned long x = bufferLong [a*2+1];   // Get high buffer entry
    byte y = x;                             // Mask off first character
    lc.setRow(3,a,y);                       // Send row to relevent MAX7219 chip
    x = bufferLong [a*2];                   // Get low buffer entry
    y = (x>>24);                            // Mask off second character
    lc.setRow(2,a,y);                       // Send row to relevent MAX7219 chip
    y = (x>>16);                            // Mask off third character
    lc.setRow(1,a,y);                       // Send row to relevent MAX7219 chip
    y = (x>>8);                             // Mask off forth character
    lc.setRow(0,a,y);                       // Send row to relevent MAX7219 chip
  }
}

Mas tarde te lo simulo a ver si veo el error.
cual es la librería, la del tutorial de max?

Solucionado el problema, era el display que estaba invertido, ahora a trabajar con mas de un display, gracias por todo el apoyo, si alguien tiene algun comentario como hacerlo se le agradece

Juka

También solucionado, si alguien quiere el código que solo lo diga

El próximo desafío es ingresar el texto solo por teclado y arduino, sin pc...........se puede???????

Juka

Claro, pero si tienes un UNO tendrás que trabajar un poco mas.
Con Leonardo, DUE y no recuerdo el tercero es directo.
Carmeloco o Max_saeta confirmaron que modificando el Bootloader del UNO puede convertirse en un dispositivo HID
Este es un ejemplo

Saludos
Puedes conectar un teclado pos PS2 ya que trabaja por I2C Tecladp PS2

con el mega se puede???

por lo que vi esta referido al leonardo

Espero srepuesta

Juka

alguien sabe como como agregarle el modulo bluetooth HC 05 para mandas los mensajes desde el celular

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

const int numDevices = 4;      // number of MAX7219s used
const long scrollDelay = 10;   // adjust scrolling speed

unsigned long bufferLong [14] = {0};


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

const unsigned char scrollText[] PROGMEM ={
   "HOLA"};

void setup(){
   for (int x=0; x<numDevices; x++){
       lc.shutdown(x,false);       //The MAX72XX is in power-saving mode on startup
       lc.setIntensity(x,10);       // Set the brightness to default value
       lc.clearDisplay(x);         // and clear the display
   }
}

void loop(){
   Serial.begin(9600);
   Serial.println("empieza el programa");// solo para visualizar en monitor serial
   scrollMessage(scrollText);
   Serial.println("setup");// solo para visualizar en monitor serial  
     scrollFont();
   Serial.println("cierra el setup");// solo para visualizar en monitor serial
   
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

const unsigned char font5x7 [] PROGMEM = {      //Numeric Font Matrix (Arranged as 7x font data + 1x kerning data)
   B00000000,  //Space (Char 0x20)
   B00000000,
   B00000000,
   B00000000,
   B00000000,
   B00000000,
   B00000000,
   6,

   B10000000,  //!
   B10000000,
   B10000000,
   B10000000,
   B00000000,
   B00000000,
   B10000000,
   2,

};

void scrollFont() {
   Serial.println("scroll");
   for (int counter=0x20;counter<0x80;counter++){
       loadBufferLong(counter);
       delay(500);
   }
}

// Scroll Message
void scrollMessage(const unsigned char * messageString) {
   Serial.println("mensaje");
   int counter = 0;
   int myChar=0;
   do {
       // read back a char
       myChar =  pgm_read_byte_near(messageString + counter);
       if (myChar != 0){
           loadBufferLong(myChar);
       }
       counter++;
   }
   while (myChar != 0);
}
// Load character into scroll buffer
void loadBufferLong(int ascii){
   Serial.println("load");
   if (ascii >= 0x20 && ascii <=0x7f){
       for (int a=0;a<7;a++){                      // Loop 7 times for a 5x7 font
           unsigned long c = pgm_read_byte_near(font5x7 + ((ascii - 0x20) * 8) + a);     // Index into character table to get row data
           unsigned long x = bufferLong [a*2];     // Load current scroll buffer
           x = x | c;                              // OR the new character onto end of current
           bufferLong [a*2] = x;                   // Store in buffer
       }
       byte count = pgm_read_byte_near(font5x7 +((ascii - 0x20) * 8) + 7);     // Index into character table for kerning data
       for (byte x=0; x<count;x++){
           rotateBufferLong();
           printBufferLong();
           delay(scrollDelay);
       }
   }
}
// Rotate the buffer
void rotateBufferLong(){
   Serial.println("rotacion");
   for (int a=0;a<7;a++){                      // Loop 7 times for a 5x7 font
       unsigned long x = bufferLong [a*2];     // Get low buffer entry
       byte b = bitRead(x,31);                 // Copy high order bit that gets lost in rotation
       x = x<<1;                               // Rotate left one bit
       bufferLong [a*2] = x;                   // Store new low buffer
       x = bufferLong [a*2+1];                 // Get high buffer entry
       x = x<<1;                               // Rotate left one bit
       bitWrite(x,0,b);                        // Store saved bit
       bufferLong [a*2+1] = x;                 // Store new high buffer
   }
}  
// Display Buffer on LED matrix
void printBufferLong(){
 Serial.println("print");
 for (int a=0;a<7;a++){                    // Loop 7 times for a 5x7 font
   unsigned long x = bufferLong [a*2+1];   // Get high buffer entry
   byte y = x;                             // Mask off first character
   lc.setRow(3,a,y);                       // Send row to relevent MAX7219 chip
   x = bufferLong [a*2];                   // Get low buffer entry
   y = (x>>24);                            // Mask off second character
   lc.setRow(2,a,y);                       // Send row to relevent MAX7219 chip
   y = (x>>16);                            // Mask off third character
   lc.setRow(1,a,y);                       // Send row to relevent MAX7219 chip
   y = (x>>8);                             // Mask off forth character
   lc.setRow(0,a,y);                       // Send row to relevent MAX7219 chip
 }
}

hola a todos los de gran ingenio quería preguntar como se puede modificar o cambiar los led de una matrix7219 eso que vienen con la matrix 8x8 si se podra cambiar a led mas grandes normales y si se puede hacer de 8x6 como podria hacerlo?

No revivas hilos viejos. Crea un nuevo con tu inquietud y antes lee las normas del foro