Arduino nano + Charlieplexed PWM LED Matrix Driver - IS31FL3731

Hello,

A little test i did before implementation in the final project:

#include <Adafruit_IS31FL3731.h>
Adafruit_IS31FL3731 matrix = Adafruit_IS31FL3731();


byte ProgramChange = 0XC0;

//light up led at pin 13 when receiving MIDI msg

void setup(){

    
  Serial.begin(31250);
  
  matrix.setTextSize(1);
  matrix.setTextColor(15);
  matrix.setCursor(1,1); 
    
}

// ***** RETURN THE PROGRAM NUMBER IF A PROGRAM CHANGE OCCUR *****
byte checkMIDI(){

byte b;
boolean mem;
byte PrgNb;

mem=false;

PrgNb=0;

  while (Serial.available() > 0){

    b = Serial.read();//read first byte

   // matrix.clear();
   // matrix.print(String(b)); 
    
    if ((b==ProgramChange) && (not mem)){     // if it's the first Program Change received
 
      mem=true;
        
      PrgNb = b;
       
    }
  }
  return PrgNb;
}

void loop(){

  byte b;

  b=checkMIDI();

  if (b>0){
    digitalWrite(13,HIGH);//turn led on  // if Display doesn't run as well
    delay(250);
    digitalWrite(13,LOW);//turn led off
        
  }
  delay(100);
}

This code running well (without matrix display), LED on bord light on when i send a Program Change message to the Arduino.
But if i uncomment this lnes:

   // matrix.clear();
   // matrix.print(String(b));

Nothings append... why ?
Many thank's
Lilian.

Topic moved at the request of the OP

Hi Lilian, please explain what you mean by

Nothings append...

Hello,

While this lines are commented, the LED ligths when a MIDI message is sent.
If i uncomment, even LED and matrix dosen't light up...
I think the Serial.read() doesn't return a right byte (same midi msg is same each time).

If you have any idea...

Thank's !
Lilian

The library Adafruit_IS31FL3731 will have some example sketches, which were downloaded with the library. Did you try any of these sketches to test that your wiring is correct and that the matrix is working?

If the matrix works ok with the test sketches, compare your sketch with the example sketches to see if there is something missing from your sketch.

(I can tell you that there is something missing, something important, but I would like you to try to find it yourself, you will learn more that way.)

Hello,

It was a great idea... the matrix work... i saw i miss a line to initiate matrix ( matrix.begin() )
Beginner error...
I already wrote more than 650 lines in the final project... still/always a beginner :grinning:

I have a new test to do, because i lost some bytes from serial when matrix is in use... i will come back with more informations...

Many thank's !
Lilian.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.