saving RX input to array

i´m having a problem trying to save the System Exclusive Message ( MIDI ) from a synth
to an array .. it never gives , doit=1;

here is my code

void receiveSysex() {
  
             
  
        
            
            
            
            
            byte casioRe[]={0xF0, 0x44, 0x00, 0x00, 0x70, 0x10, 0x60 , 0x70, 0x31 , 0xF7} ;
            
            //Serial.write(casioRe, sizeof(casioRe)); 
            //Serial.flush();
            
            MIDI.sendSysEx(10, casioRe, true);
            
            
            MIDI.read();
            
            int doit=0;
            const byte *  MyArray;
            
            MyArray = MIDI.getSysExArray();
            
            if (MyArray[0]==0xF0){
            data[0]=0xF0;
            
            
            for (int i=1; i=264;i++){
              data[i]=MyArray[i];
              doit=1; }
            }
            


 if (doit==1)
    {    // SAVE to file ............

also i tried doing this and some times works,,,

byte casioRe[]={0xF0, 0x44, 0x00, 0x00, 0x70, 0x10, 0x60 , 0x70, 0x31 , 0xF7} ;
           
           Serial.write(casioRe, sizeof(casioRe));
           Serial.flush();




 //--------------------------
 byte midiByte;
 int doit=0;
 int index=0;
 
 if ( Serial.available() ) {
  
   midiByte = Serial.read();   
   if (midiByte==0xF0){
   data[0]=0xF0;
   index=1;

 while (Serial.available()) {     
 data[index] = Serial.read() ;
 index++;   doit=1;         }

  
                        
 }
 
 }

//-----------------------




if (doit==1)
    {    // SAVE to file ............

Please go back and edit your posts to put the code in code tags (use the button like a scroll with <>)

so it looks like this and is easy to read and select.

I am not a musician so I know nothing about midi. However the example programs in serial input basics may give you some ideas.

...R

After 27 posts, you'll find you have better responses if you follow the guidelines found in the two posts by Nick Gammon at the top of this Forum. Posting the code the way you do is wrong and you're wasting a lot of pico acres in the process.

Hello , just arrive , home sorry .

Robin2 , Thanks i will read that right now , but please if any one can give me more clues ...

i´m getting good results with this code

:grinning:

void receiveSysex() {
  
             
  
            
           
            
            
            //F0 44 00 00 70 10 60 70 31 F7 request patch from CURRENT SOUND area
            
            byte casioRe[]={0xF0, 0x44, 0x00, 0x00, 0x70, 0x10, 0x60 , 0x70, 0x31 , 0xF7} ;
            
            Serial.write(casioRe, sizeof(casioRe)); //retrive the patch from CURRENT SOUND area 
            Serial.flush(); //flush all previous received and transmitted data
            
            
            
            
      


//--------------------------
 byte midiByte;
 int doit=0;
 int index=0;
 

while(!Serial.available()) ; // hang program until a byte is received 
 
 
// only if there are bytes in the serial buffer execute the following code 


if (Serial.available()>0)
 {
   
   midiByte = Serial.read();   
   
   if (midiByte==0xF0)
   {
   data[0]=0xF0;
   index++;
   doit=1;
   
    //keep reading and printing from serial untill there are bytes in the serial buffer
   while (Serial.available()>0)
                               {
                                 data[index] = Serial.read(); 
                                //Serial.print(data[index], BYTE); //prints the character just read
                                 index++;
                                }
    
    }
                
 }


 if (doit==1)
    {  // save to file ....