Tscope5
timer05.c
////////////////////////////////////////////////////////////////////////////////
//
// __ ______
// / /_______________ ____ ___ / ____/
// / __/ ___/ ___/ __ \/ __ \/ _ \ /___ )
// / /_(__ ) /__/ /_/ / /_/ / __/ ____/ /
// \__/____/\___/\____/ .___/\___/ /_____/
// /_/
//
// timer05.c
// - Change the stimulus while waiting for a response.
// - Instructions: press S when an S appears, press L when an L appears.
////////////////////////////////////////////////////////////////////////////////
#include <tscope5.h>
int main()
{
// open a display
ts5_wait(2.0);
// define response buttons
double start, stop, rt, error;
int i;
for (i=0; i<5; i++) {
// fixation
ts5_printf(0.0, 0.0, "+");
ts5_wait(0.5);
// stimulus
unsigned int stim = ts5_random_integer(2);
if (stim==0) {
stim='S';
}
else {
stim='L';
}
ts5_printf(0.0, 0.0, "%c", stim);
start = ts5_flip_display();
// flush the response buffer after stimulus onset
// clear the display after 0.5 seconds
// if a response occurs during this interval it is buffered
ts5_wait(0.5);
// wait until 2 seconds after the stimulus
int resp = ts5_wait_for_response_until(&stop, &error, start + 2.0);
// compute and print RT
rt = stop-start;
ts5_printf(0.0, 20.0, "response %d", resp);
ts5_printf(0.0, 0.0, "rt %f", rt);
ts5_printf(0.0, -20.0, "measurement error %f", error);
// iti
ts5_wait(2.0);
}
// wait for a click
ts5_draw_mouse_button(ax(0.9), ay(-0.8));
return 0;
}