IMO , the loop function you have posted is the right way to approach this . That is , have your loop function do a brief update of the LED state , and terminate quickly . Adding forwhile loops and long delays to your loop function will cause your arduino to become unresponsive while the delays and internal loops are being executed . If you are checking for button presses , or processing serial communication inside the loop function then you probably don ' t want the arduino to stop doing these things while your animation is being performed . The only things that will continue to be processed while your loop function is executing are interrupts , which have their own tradeoffs , and might cause more problems for a beginner than they solve . DarthVadersAppendix has what is probably the best suggestion so far . You need to create one or more state variables that live longer than a single execution of the loop function . This can be done either with global variables , or static variables . Simplest approach I could imagine would be to wrap your animation update inside something like ifmillis gblAnimationEnd do animation ifbuttonpressed gblAnimationEnd millis animationDuration animationDuration could be 6000 msec as an example Not the only approach of course , but one that ' s straight forward , and won ' t get in the way of other things you might be doing in loop