Welcome! Log In Create A New Profile

Advanced

Triggering Arduino from goodmonkey()

Posted by Jaewon 
Triggering Arduino from goodmonkey()
January 08, 2023 05:24AM
* Requirements
MATLAB R2014a or later
NIMH ML 2.2.32 & 2.0.253 (Jan 7, 2023) or later
MATLAB Support Package for Arduino Hardware

* Instructions
1. Install the MATLAB Support Package for Arduino Hardware from the following link, if it is not installed already.
https://www.mathworks.com/matlabcentral/fileexchange/47522-matlab-support-package-for-arduino-hardware

If a download error occurs while installing the Support Package, see this link. It works for R2014a 32-bit as well.
https://www.mathworks.com/support/bugreports/1741173

2. Copy 'alert_function.Arduino.m' from the NIMH ML directory to your task folder and rename it to 'alert_function.m'.
function alert_function(hook,MLConfig,TrialRecord)

switch hook
    case 'init'
        MLConfig.DAQ.set_reward_object(MLConfig,arduino);
end

end

3. After loading the task, turn on the [Alert] button on the [Task] panel of the main menu.
https://monkeylogic.nimh.nih.gov/docs_AlertFunction.html

4. Use the JuiceLine option of the goodmonkey function, to specify a particular digital pin.
goodmonkey(100,'juiceline','D2');  % use the D2 pin; R2015a or later
goodmonkey(100,'juiceline',2);     % R2014b or earlier uses a numeric pin number

The National Institute of Mental Health (NIMH) is part of the National Institutes of Health (NIH), a component of the U.S. Department of Health and Human Services.