char ArrayBuffer[][4] = {}; // holds four characters, must be
declared as global to loop()
in
loop()
{
byte Index = 0; // initialize array index
if(Serial.available()) // have data in Serial buffer
{
byte Count = Serial.readBytes(ArrayBuffer[Index],4); // read //4 //characters into array buffer , returns actual number //of characters //read and times out if less than 4 characters are //currently in Serial buffer
Serial.println(ArrayBuffer[Index]); // print buffer to monitor
}while(++Index != 4); // read 4 by 4 characters from incoming stream
}
...
continue with loop - process ArrayBuffer as required
}
This is one way to get the incoming stream from Serial buffer into for individual buffers, however, it is better, less chance of misdirecting the data into wrong buffer (index) to read the entire buffer at once instead of using he readBytes four times.
Just my opinion, your mileage will vary.
PS what is the trick to format the code and text correctly ?
This is a mess.
I cannot get the code block to indent, I can get only the first ( four spaces line.
for
andwhile
loops?