Serial Monitor Not Processing Numbers above 9

Hello All!

I am a newbie and unfamiliar with how to incorporate parseInt() into the code. I am limited to testing components associated with menu selections 1-9 in the serial monitor. If I attempt to test component associated with menu number 11 it will test component associated with menu selection 1 twice.

Code and Wiring

Please help!

The problem is that serial read only reads the first character entered. From the documentation:

The first byte of incoming serial data available (or -1 if no data is available). Data type: int

A simple way to fix this issue would be to use letters after 9. 10 would be A, 11 would be B, etc. Giving you 35 options.

Good Morning,

Thank you so much for your reply. I really appreciate the information you provided. I researched this for a few days and could not find the answer. I replaced the numbers above 9 with alphabets as you suggested and it worked!!!

Thank you!!!

1 Like

For the record, there are other ways of fixing this, but this seemed the simplest. A better “fix” might be to read a string from the serial port but then all the code that compares with single quotes would have to be changed to double quotes for strings (not single characters). So as I said, this approach is simpler and quicker if 35 options is enough. I guess you could get more if you’re willing to use other characters. :wink: