We just had this discussion on the (could be wrong) thread. You have two options:
-
Use the Blink-Without-Delay technique and cut your long function down into smaller parts so that it can never exceed the time budgeted for the loop.
-
Put your time sensitive function on a timer interrupt.
#2 is the more difficult technique. There are very few libraries to help you with this. Most of the libraries such as Timer and SimpleTimer actually use the #1 technique. Timer1 might be a useful one although I have not used it myself.