Latency between visual stimulation and trigger from arduino

How are you controlling the Arduino from MATLAB? My experience with the current MATLAB hardware package is the timing is awful (I timed a minimal command-response time of ~30ms). In addition it is annoying as hell to set up and installs hundreds of megabytes of unnecessary dependencies…

What I ended up doing was switching to the older Mathworks legacy hardware interface, which uses the serial port and much much faster. I ended up rewriting the code to use PTB’s IOPort and the command-response time dropped orders of magnitude, you can see some comparisons here: Serial port interface code -- a performance comparison – I also rewrote the controller, so that variable length TTL’s do not block the main PTB loop. This means I can get very fast (submillisecond) command-response control from PTB.

Are you sure your arduino code itself is not doing something that can also introduce the delay? And how are you polling the arduino to “trigger” PTB’s screen flips?