I am trying to learn Arduino IDE language. An issue has come up that I am unable to debug nor understand.
When writing a command line, if the instruction is correct, it highlights orange in the sketch. However, that is not happening when i write the "while" command, such as attached. Rather the "while" instruction appears as a light black or blue (which i can barely distringuish from the remaining text).
Can anyone explain what that is happening? Secondly, how to correct the issue?
Delta_G:
There are IDEs where the color means something. Unfortunately the Arduino IDE isn’t one of them.
Well, they mean something, specifically that the colored word is listed in the keywords file. This can be helpful when you don't remember the capitalization or spelling of some function or keyword. But that's about it, and not every library supplies comprehensive keyword files.
The color of the command language must have some function, if not just for editing and writing. I see it orange in the reference library on the Arduino site (as well in other code using the "while" structure). Just it does not appear in my code. In fact, the while command often moves on to the next while loop before I even provide it the integer. So something is missing in interpretation/compiling. I have what I believe to be the latest version of the IDE (1.8.10). I will drudge on and keep writing/experimenting.
Let's see if i can explain it better since I am new. First I must ask, what does the "while" command do? Isnt it suppose to wait until an input is provided and read through the serial monitor? such as the instruction:
while(Serial.available() == 0) { }
I have two of these commands in the code i posted. What happens is the first "while" loop runs before I input the integer for the second while loop.
What happens is the first "while" loop runs before I input the integer for the second while loop.
What have you got the line ending set to in the Serial monitor ?
Try this with various line ending settings. Restart the Serial monitor after changing the line ending settings
void setup()
{
Serial.begin(115200);
while (Serial.available() == 0) {}
int anInt = Serial.parseInt();
Serial.println(anInt);
if (Serial.available() != 0)
{
Serial.println("something still in the buffer");
}
}
void loop()
{
}