Arduino support package send two value at the same time to different port
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Pratik
2024-5-15
Hi Fan,
As per my understanding, two arduino boards are to be connected to a computer via different ports and two different triggers are to be send to the ports separately.
This can be achieved by creating two Arduino objects. "parfevalOnAll" can be used to run an initialization on each worker that creates an arduino object and stores a reference to it .
Please refer to the following MATLAB Answer which shows how to identify a worker:
Also, please refer to the documentation of "parfevalonall" for more information on running function on all workers in background:
I hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 EEG/MEG/ECoG 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!