How to count number of bytes appearing in the Arduino serial?
Serial.available() returns the number of bytes available for reading in the buffer.
int nBytes=Serial.available();
if (nBytes &gt; x) {
............
............
............
}