Need to create a new line in output for every second

I have a very simple Routine, where people just need to keep pressing spacebar.
I need to show in this Routine output, for every second, the total amount of times spacebar have been pressed.

if Time == Seconds [0]:
    thisExp.addData('Pressões',Pressoes)
    thisExp.addData('Time',Time)
    Seconds = Seconds [1:]

It seems that using this code in every frame, only one line is saved on the output, with the total amount of presses right before the Routine ends (end called by time).

‘Seconds’ list is composed of every second on the routine, and created on experiment beggining:

Seconds = [*range(0, RoutineDuration, 1)]

Is it possible to make this work without having to call multiple routines with 1s duration each?

You want thisExp.nextEntry()

You could also simplify your Seconds by using Seconds =0 in Begin Routine

if t> RoutineDuration:
     continueRoutine =False
elif t>Seconds:
     Add data etc 
     Seconds +=1
1 Like

Thank you, that is exactly what I needed.
Also, this way of using seconds really is a lot better, thanks for the advice.

1 Like