Hello,
Any idea how to create a countdown clock that counts down from 5 minutes across trials and ends the loop after five minutes?
Thanks,
Janelle
Hello,
Any idea how to create a countdown clock that counts down from 5 minutes across trials and ends the loop after five minutes?
Thanks,
Janelle
Insert a code component. In its “Begin routine” tab, put something like:
# only do the set-up once:
if your_loop_name.thisN == 0:
task_timer = core.CountdownTimer(start = 300) # duration in seconds.
In the “Each frame” tab, put something like this:
# end task after 5 min:
time_left = task_timer.getTime()
# optional - only needed if you want to display these to the subject:
minutes = int(time_left/60)
seconds = int(time_left - minutes * 60)
if time_left <= 0.0:
your_loop_name.finished = True
continueRoutine = False
It’s not clear from your message if you actually want to display the countdown to the user. But if so, put something like this in a text component’s text field, set to update on every frame (make sure the code component is above the text component):
$f'{minutes}:{seconds}'
If you would like to run the experiment online then you will need to use a normal clock and subtract its value from 300.
Hi @Michael, I need to make a visible millisecond countdown, just like @jan1 . Thanks to your comments I can do it but I want the loop doesn’t end and the countdown to start again with each trial. I also need people to be able to stop it with any key. How can I do it? thank you!
Then just delete this code:
if time_left <= 0.0:
your_loop_name.finished = True
continueRoutine = False
Just delete this code:
# only do the set-up once:
if your_loop_name.thisN == 0:
Stop what, the countdown display or the whole routine?
Thank you soo much! I added an answer key after the countdown to stop it. Thanks again!