Have a look at, and more importantly play with, the blink without delay example in the IDE, without delay.