Tscope5
timer3.c

timing with maximum response time

#include <tscope5.h>
int main()
{
ts5_wait(2.0);
double start, stop, rt, error;
int i;
for (i=0; i<5; i++) {
ts5_printf(0.0, 0.0, "+");
unsigned int stim = ts5_random_integer(2);
if (stim==0) {
stim='S';
}
else {
stim='L';
}
ts5_printf(0.0, 0.0, "%c", stim);
ts5_wait(0.5);
start = ts5_flip_display();
int resp = ts5_wait_for_response_timed(&stop, &error, 2.0);
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);
ts5_wait(2.0);
}
return 0;
}