Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
Fan Yang
Fan Yang am 27 Sep. 2021
Beantwortet: Pratik am 15 Mai 2024
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

Antworten (1)

Pratik
Pratik am 15 Mai 2024
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!

Kategorien

Mehr zu EEG/MEG/ECoG finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by