Thanks for this. I did start off with delay() but that produces loops that are always longer than the timestep I want. In the real programme the loop actually takes somewhere between 120 and 200 ms to complete. I am always open to suggested improvements.