fergieomni:
Hi John, I am currently facing same issue with the OP. Appreciate your help to instruct me how to store the arrives data into buffer then compare with desired data. Thanks in advance!!!
Change this
Serial.print(key);
to
Serial.println(key, HEX);
That will show you exactly what is received (in hexadecimal representation) so you can determine if there are markers (e.g. '\n' (0x0A) as an endmarker). See e.g. http://www.asciitable.com/ if you need help with the codes that you see.
You will need to read up on arrays to store the data; Serial Input Basics shows how it is done for serial communication but you can apply the principles to your scenario.
The compare can be done with e.g. strcmp() (text based) or memcmp (binary based).