void loop() {
//n1000 = micros();
//while ( n1000 > 1000000L) n1000 -= 1000000L; // This works
// n1000 = micros() % 1000000UL; // This hangs Arduino while pressing reset
n1000 = micros();
n1000 %= 1000000UL;
if ( !dOn && ( n1000 >= 500000L ) ) {
digitalWrite(dummyPort, 1);
dOn = true;
}
if ( dOn && ( n1000 < 500000L ) ) {
digitalWrite(dummyPort, 0);
dOn = false;
}
[glow] delay(1);[/glow]
}
Adding shortest delay seems to make it more stable ... what does micro() do low level as that is also a constant factor in the code?