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.