Arduino support package send two value at the same time to different port
2 ビュー (過去 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!