Problem with modulo (%) and reset

In your failing code example:

 // n1000 = micros() % 1000000;
  if ( !dOn && n1000 >= 500 ) {
    digitalWrite(dummyPort, 1);
    dOn = 1;
  }  
  
  if ( dOn && n1000 < 500 ) {
    digitalWrite(dummyPort, 0);
    dOn = 0;
  }

Software isn't my strong suit, but shouldn't it be:

 // n1000 = micros() % 1000000;
  if ( [glow]([/glow]!dOn && n1000[glow]) [/glow]>= 500 ) {
    digitalWrite(dummyPort, 1);
    dOn = 1;
  }  
  
  if ( [glow]([/glow]dOn && n1000[glow]) [/glow]< 500 ) {
    digitalWrite(dummyPort, 0);
    dOn = 0;
  }

Lefty