Making a while-loop timeout

The correct way to busy wait for a time is:

while ((long) (millis() - target_time) < 0)
{}

But as has been mentioned busy-waiting isn't normally a good idea

[ not the cast to a signed type so can compare less than zero, and the subtraction before the compare
so that the wrap-around case is handled correctly ]