Hi all,
i had this question a few weeks back , after the change in flush() method it had become quite difficult to empty the serial buffer , so to all those who require to send large amounts of data from processing or serial monitor to arduino, just use this code. Only prerequisite is that the data must be sent as a bulk, no delays are required.
void loop()
{
if (Serial.available())
{
val="";
while(Serial.available())
{
char t= Serial.read();
val=val+t;
}
Serial.println(val);
Serial.end(); // Ends the serial communication once all data is received
Serial.begin(9600); // Re-establishes serial communication , this causes deletion of anything previously stored in the buffer //or cache
}
}
later u can just use the substring method to extract from val