i just experimented with the timing accuracy of my Arduino Uno R3 using this code:
unsigned long beginTime;
unsigned long endTime;
void setup() {
Serial.begin(9600); // open a serial port
}
void loop() {
beginTime = micros();
delayMicroseconds(200);
endTime = micros();
delay(500);
Serial.println(endTime-beginTime);
delay(500);
}
The results I got are (just an excerpt):
200
204
200
200
204
204
204
200
212
208
212
204
204
I tried to understand this behavior, read this link Can I make delayMicroseconds more accurate?.
Due to the timing of micros (4 µs) I would understand values between 200 and 208. But why do I get occasional values of 212 microseconds? I'm kinda curious, since I bought the Arduino because of bare-metal programming and bounded execution times.