I am working through the ReadASCIIString tutorial and I AM STUCK!
I have worked out who the different operations work but the thing I cannot get going is the conditional:
if (Serial.read() == '\n')
I am working with an ordinary PC (My machine is Intel QuadCore i5-3470 CPU @ 3.20GHz, 32 GB RAM, running MS Windows 10 Home on an MSI B75MA-P45 motherboard.) and, no matter what I try with the keyboard the conditional never returns TRUE.
Please, what is the secret?
The '' character at the start of a character constant or in a string is an escape character that allows non-printable characters to be defined in the constant. '\n' is the newline, as already mentioned, '\r' is tyhe return character. There are a whole host of these (Google "escape character C++").
In the Serial monitor you can force appending the \n\r by options selected at the bottom status bar the Serial Monitor window.
Thanks folks
marco_c:
In the Serial monitor you can force appending the \n\r by options selected at the bottom status bar the Serial Monitor window.
I think Delta_G was saying the same thing. I fiddled with the switches at the bottom of the Serial Monitor (I am using Visual Studio/Visual Micro) and all is well.
Cheers