What is the easiest way to run some code each millisecond for a certain amount of time?

Look at the ticker.h library.