So I assumed when the “send” or “enter” was pressed the entire string was passed to the interface.
1. In the InputBox of the 9600 Bd Serial Monitor, we enter <12345> and then press the Send button. After that the following events occur:
(1) The PC sends the ASCII Code of < which is (00111100 = 0x3C) in a 10-bit frame called UART Frame where LSBit is transferred first. The frame transmission time from PC to UNO is about : 10x1/9600 = 1041 us. The PC will send 7 such frames one after another at 1041 us apart.
(2) The UNO receives a frame and finishes the processing far less that 1041 us. The 8-bit character enters into the Receiver Section of the UART Module of the MCU and interrupts the processor. The processor goes to the ISR (Interrupt Sub Routine) and saves the data (character) byte into a 64-byte wide FIFO Buffer.
(Assume that we not reading data/character from the FIFO Buffer)
(3) The next character 1 enters into the next location of the FIFO Buffer and so on.
(4) The Arduino Platform has given us (that’s why, the Arduino is so popular to the Logicians) us a function called byte x = Serial.available(); by which we can check how many charcaters so far been accumulated in the buffer.
(5) Arduino has also given us another function called byte y = Serial.read(); by which we can transfer a data/character from the FIFO buffer (the character that has entered first in the FIFO will come out first) into the variable x for processing.
2. It is hoped that the above points are enough to clarify the meanings of the following commands:
//do as needed
if(Serial.available() == 3)
//do as needed