Jairak wrote:
If I want to count 2 second working in the loop and next then going out of the loop
I don't know which the loop I can use
If you know the time/iteration of the loop, you can easily calculate how many iterations you need until 2 seconds are up. This means you can use a FOR loop. You always use a FOR loop of you know the number of iterations before the loop starts.
If the time per iteration is varaible or unknown, and you cannot know how many iterations will be needed until 2 seconds are up, you need a while loop. In a while loop, you need to test yout stop condition at each iteration. In this case, you would check if 2 seconds have elapsed.
A timed loop is more precise at keeping a defined time per iteration and can even tell you if an iteration finishes late do to too much code. It is more useful in conditions where the time per iteration needs to be very precise.
Overall, you should probably start with a few tutorials and look at the help pages of the various loops to get familiar with the differences. Do you have experiences in any other programming languages?.
You could also try to describe im much more details what you are actually trying to do and we might have more specific suggestions. 🙂