Arduino support package send two value at the same time to different port

2 views (last 30 days)
Fan Yang
Fan Yang on 27 Sep 2021
I need to trigger EEG and fMRI at the same time by a visual stimulation I wrote in matlab. I can use the arduino support package to trigger trigger to the EEG system sychronzing the visual stimuli and EEG recording, but I also need to trigger the fMRI scanner. I am thinking connect two arduino boards to my computer via different ports and send two triggers to two ports respectively and simultaneously. How can I do that?
I wrote the code below to synch EEG and visuals stim.
P.S. the visual stim were writen using the VisualStimulus toolbox version 1.0 by Michael Beyeler.
a = arduino('com3','uno'); % Create an adrduino object
f = figure; f.WindowState = 'maximized'; % max the figure window
for deg = (0:7)*45
blank = GratingStim([300 500],'k',20,deg,[1,1],0.1);% generate a blank pic
blank.plot % plot the blank picture
grating=GratingStim([300 500],'k',20,deg); % generate stimuli
writeDigitalPin(a,'D4',1) % write to EEG to start recording
grating.plot % plot the stimuli
writeDigitalPin(a,'D4',0) % write to EEG to end recording
end
clear a % delete the arduino object

Answers (0)

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!