Making somthing run for X amount of time

See Using millis() for timing. A beginners guide, Several things at the same time and the BlinkWithoutDelay example in the IDE