Have a look at the blink without delay example for a means of delaying but still allowing the processor to do other things