End loop after 5 minutes

Hi @hkim174,

The code you’ve written looks correct but might be in the wrong place. With clock.reset() in Begin Routine, your clock will reset with every trial and will never reach 300 seconds. You need two components, one to create & start the clock, the other to check the clock.

Component 1: Create and start the clock

  • this component should be in the routine immediately before your loop starts (e.g. your loop is trial so you want Component 1 to be in blank_1000ms

  • this routine should contain the following code:

    • Begin Experiment
    newClock = core.Clock()
    
    • End Routine
    newClock.reset()
    

    I recommend end routine to start the clock and match it closely with when the loop starts

Component 2: Check the clock

  • this component should be in the routine inside the loop (e.g. your loop is trial so you want Component 2 to be in Recall1
  • this trial should contain the following code:
    • Each Frame
    if newClock.getTime() >= 300:
    trial.finished = True
    

See also: Ending an entire experiment after a set time (60 minutes)

Hope that helps,
-shabkr

2 Likes