Hi everyone,
I am trying out a very simple program to send a fixed decimal number(e.g number 10) to computer through USB Serial at fixed timing intervals.
Here is a screenshot of the program:
This code works fine when I send one message per 10 ms (i.e 1000 * 10 micro second). The timing of received message is measured on my computer(0.01s delay between messages):
However, If I change the timing to one message per 1 ms, the received timing is wrong(computer is getting .00004s delay between messages):
Since my only change is the check on elapsedMicros, I am feeling this is a bug on the library/hardware (or am I missing something obvious? )
Any help is appreciated!
I am trying out a very simple program to send a fixed decimal number(e.g number 10) to computer through USB Serial at fixed timing intervals.
Here is a screenshot of the program:
Code:
elapsedMicros sinceLastRead;
void setup() {
Serial.begin(9600);
}
void loop() {
if (sinceLastRead > 1000 * 10) {
sinceLastRead = 0;
Serial.println(10);
}
}
This code works fine when I send one message per 10 ms (i.e 1000 * 10 micro second). The timing of received message is measured on my computer(0.01s delay between messages):
However, If I change the timing to one message per 1 ms, the received timing is wrong(computer is getting .00004s delay between messages):
Code:
elapsedMicros sinceLastRead;
void setup() {
Serial.begin(9600);
}
void loop() {
if (sinceLastRead > 1000 * 1) { // change is HERE
sinceLastRead = 0;
Serial.println(10);
}
}
Since my only change is the check on elapsedMicros, I am feeling this is a bug on the library/hardware (or am I missing something obvious? )
Any help is appreciated!