I have been having a problem with Serial.print() printing data out of order, with extra line breaks, and repeating data. Here is the simplest example:
int x = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println(x);
x++;
}
Here is what the Serial Monitor Displays
1
2
3
4
1
2
3
4
5
6
7
8
5
6
7
8
9
10
11
12
9
10
11
12
13
14
15
16
13
I am an Engineering and Robotics Teacher using the Web Editor IDE. My students have Chromebooks, so I have to use the Web Editor. For the past few years the Serial.print() commands worked exactly as expected. I first noticed this problem last spring. I am using an Arduino Uno R3 that is a few years old (purchased in 2021).
Here are things I have tried and have not worked:
-Switching computers
-Switching Arduino Unos (all 2+years old)
-Using the Board Manager in Arduino IDE to update the board
-Adding delays before and after each line
-Adding a Serial.flush() before and then after the print
-Tried uploading sample code from the Arduino Serial.print() documentation (similar problems with output)
-The value stored in the variable appears to be updating correctly (it increases the brightness of an LED predictably.
Things that have resolved the problems.
-The Arduino Nano 33 IoT board completes the Serial Print without problems. (I own 80 starter kits with Arduino Rev 3 boards and I would like to not have to replace them all)
-The problem does not occur in the IDE, just the Web Editor. (My students use the web editor with their Chromebooks)
I am at my wits end, hopefully someone has seem and solved this problem. Thanks in advance.