Your code for reading the serial data is not at all robust. You don't even check to see if there is data available to read.
Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.
...R
Your code for reading the serial data is not at all robust. You don't even check to see if there is data available to read.
Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.
...R