See blink without delay in the example sketches in the IDE. Lets you control how often something is performed.