I am using Arduino Due in windows 11. In my code, I have to give some input in the serial monitor to run the sketch, but when I provide the desired input and press Ctrl+Enter, input data is not getting accepted by the code. Am I doing something wrong?
Everything works perfectly when I do the same thing without any change in IDE 1.8.19. Is it a bug or am I doing something wrong?
I seem to experience the same problem as @anon78116600. Serial Monitor does receive data but does not send; the Rx LED on the Nano does not flash.
I type a character in serial monitor and press <enter>, no reaction. I notice that there is no send button as in the 1.8.x version but that might have been the case with all IDE 2.0 versions.
This applies to both RC8 and RC9; I've just deleted older versions so can't check.
"Installations" are ZIP versions. Code works as expected in 1.8.5.
Hi @sterretje. Unfortunately the established Enter is not currently supported by the Arduino IDE 2.x as a send trigger. You must use Ctrl+Enter instead.
This issue is being tracked by the Arduino IDE developers here:
If you have a GitHub account, you can subscribe to that issue to get notifications of any new developments related to this subject.
If you have any problems with the Serial Monitor when using the current Ctrl+Enter keyboard shortcut, please do let us know. I am interested in investigating the problem reported by @anon78116600, but there is currently not sufficient information in the report for me to be able to proceed with that.
This is being tracked by the Arduino IDE developers here:
Thanks a lot; it's working. I think that somewhere I knew about the <ctrl><enter> but did forget Ah, found it, the text in the input field. I'm so embarassed
I had the same confusion when I started using the new IDE. It is true that the placeholder text explains it, but that text disappears as soon as you start typing in the field. I didn't bother to read it in advance, and then it wasn't there to read once I needed it.
Interesting. I'm not sure how I feel about it. I think that it does exacerbate the poor user experience resulting from the unintuitive change to the keyboard trigger. It might be that once the standard keyboard trigger is restored we will find that the Send button is superfluous.
You can see that the designer did choose to add a Send button to the Arduino IDE 2.x Serial Plotter:
I was trying Ctrl + enter but no success in IDE 2.0. I tried some other codes only to try user input, that worked. Below is my code part which is working perfectly alright in IDE 1.8.19:
Serial.println("Insert the y position:");
while (k == 0) {
Kin2 = Serial.readStringUntil('\n');
if (Kin2 != "") {
k = 1;
y1 = Kin2.toDouble();
}
}
Hope this will help to investigate the problem further.
I think the issue in my case is I am trying to get user input once and this is an input that should work with other setup parameters in void setup(). And it is not working under the setup(). Will there be any change in the code if I want to use it in setup()?
I am using Arduino due. I tried both way ( putting user input in setup() and loop()), none of them worked in IDE 2.0 rc9.2 (with Ctrl + [Enter]), but working perfectly in IDE 1.8.9. (with [Enter]). I tried on multiple computers with Windows 11, same issues.
int ans = 0;
int usrAns = 0;
String userAns;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Go to Home Poisition? (0 = No; 1 = Yes) [0/1]: ");
while (ans == 0) {
userAns = Serial.readStringUntil('\n');
if (userAns != "") {
ans = 1;
usrAns = userAns.toInt();
Serial.println(usrAns);
}
}
}
The other code is:
int ans = 0;
int usrAns = 0;
String userAns;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Go to Home Poisition? (0 = No; 1 = Yes) [0/1]: ");
while (ans == 0) {
userAns = Serial.readStringUntil('\n');
if (userAns != "") {
ans = 1;
usrAns = userAns.toInt();
Serial.println(usrAns);
}
}
}
void loop() {
// put your main code here, to run repeatedly:
}
I get this output in Serial Monitor at 1 Hz when I don't provide any input:
string: ▯▯
int: 0
This results from a known bug in the Arduino IDE 2.x Serial Monitor, which is being tracked by the developers here:
Depending on the timing, you might get this spurious data in addition to the intentionally sent data. For example sending a '1' might result in this:
string: ▯▯1
int: 0
Note that even though I sent a '1', the extra garbage caused userAns.toInt() to return 0.
Something I should mention is that the rectangles ( .notdef glyph?) seen in the Serial Monitor output disappear when you copy and paste that text to a post on the Arduino forum. I actually replaced them with equivalent visible characters in my post above in order to accurately represent the text in the Serial Monitor.
This screenshot shows the actual Serial Monitor contents: