When you are using millis() for timing, you don't need to insert special little delays in an attempt to delay "just enough" to get to the next time. Have it check the millis() timer several thousand times per second (yes, more than once per millisecond) and then it will do the required action at the required time. The Arduino never gets bored asking "are we there yet?" billions of times over.
void loop() {
// put your main code here, to run repeatedly:
t=millis();
if(t - old_t >= delay){
old_t += delay;
/*point where some further code may be added*/
data[0]=t%256;
data[1]=(t/256)%256;
data[2]=(t/256/256)%256;
data[3]=(t/256/256/256);
Serial.write(data, 27);
}
}
The % operator is actually absurdly slow. It's best to avoid using it. However simple powers of 2 such as 256 are detected by the compiler as a special case and it will usually generate extremely efficient code. You might look up the right-shift operator (>>) and see how that may help with your particular example.