How to make a timed loop?

Hey Everyone,

I have an experiment in which I have a loop that shows a fixation point followed by a stimulus for random time intervals (1-6seconds). The participant then is represented with the same stimulus and has to estimate how long the previous stimulus was by pressing a key. I want the total loop to go for 20 minutes. How do I do that?
I have tried adding a timer and equating that to the limit but it is not working.
Will appreciate any help :slight_smile:

Hi There,

You can make your own clock using

myClock = core.Clock()

This will need to go in the last routine before your loop, in a code component :code: in the End Routine tab.

Then in all routines that comprise your trial (i.e. within your trials loop) you can add a code component and say:

if myClock.getTime() > (20*60):
    continueRoutine = False # end this routine
    trials.finished = True # end this loop

Finally, make sure that your trials loop has a very large number of nReps (such that it exceeds what could realistically be achieved in 20 mins.

Hope this helps!
Becca