Try this:
byte dataArray[16]; //make global declaration
void receiveEvent(int howmnay); //howmany registers the number bytes received from Master
{
for(int i=0; i<howmany; i++)
{
dataArray[i] = Wire.read();
}
for (int i=0; i<howmany; i++)
{
Serial.print(dataArray[i]); //check what you are receiving against an Intel-Hex frame
}
Serial.println();
}
OR
1. Use the 2nd field (02 after : = number of information byte in the Intel-Hex frame) as a variable (say, x). This figure could be from 00 to 20.
2. Load x with the value of the 2nd field.
3. now, repeat the above codes:
int x = 2nd field of Intel-Hex frame
byte dataArray[16]; //make global declaration
void receiveEvent();
{
for(int i=0; i<x; i++)
{
dataArray[i] = Wire.read();
}
for (int i=0; i<x; i++)
{
Serial.print(dataArray[i]);
}
Serial.println();
}