Arduino with Matlab box

Concerning processing components: filters, file load/save, visualizations, communication ...
Post Reply
Gijoco
Posts: 1
Joined: Fri Feb 28, 2020 10:51 am

Arduino with Matlab box

Post by Gijoco »

Hi everybody !

I am trying to build a BCI which will communicate with an arduino card (MKR1000). I want to send stimulation from openVibe to Arduino using the Matlab box but I get this error when I try to run a simple test program :

---- MATLAB BUFFER - ERROR ! ----
Error in send_triggeriProcess (line 6)
p=readDigitalPin(a,'D6');

I use MATLAB R2019b with the following functions :

Initialize function

Code: Select all

function box_out = send_trigger_Init(box_in)
    clear all
    disp('Matlab initialize function has been called.')
    % we add a field to save the trigger state
    box_in.user_data.trigger_state = false;
    % Don't forget to pass the modified box as output.
    box_out = box_in;
    clc
    if ~isempty(instrfind)
        fclose(instrfind);
        delete(instrfind);
    end
    global a;
    a= arduino('COM7','MKR1000');
end


Process function

Code: Select all

function box_out = send_trigger_Process(box_in)

    % we iterate over the pending chunks on input 1 (STIMULATIONS)
     for i = 1: OV_getNbPendingInputChunk(box_in,1)
         
         p=readDigitalPin(a,'D6');
        fprintf('LED = %f\n', p) 
        
     end

     % Pass the modified box as output to continue processing
     box_out = box_in;
end
readDigitalPin is a function that come from the Arduino Package of Matlab, can it be recognize by Openvibe ? Or maybe I did a mistake anywhere else ?
Every suggestion can be helpfull

Thank you

Post Reply