Thanks so much for getting back, Josh! I'm running this script directly not as a protocol. We have a valve connected through state machine to check that the script is ran through. We tried both valve on pin 7/8 and LED on pin 3/5 and changed 'V'/'L' in the script accordingly.
global BpodSystem
clear global PA1
% 1. Load the commands into Module 2 (where PA1 is connected)
% Message 1: Valve 1 OPEN (Pulls to 0V)
% Message 2: Valve 1 CLOSED (Returns to 5V)
%LoadSerialMessages('PA1', {['V',0,1], ['V',0,0]});
%% Create State Matrix
sma = NewStateMatrix();
% State 1: Pull the signal to 0V for 2 seconds
sma = AddState(sma, 'Name', 'PulseToZero', ...
'Timer', 2, ...
'StateChangeConditions', {'Tup', 'ReturnToFive'}, ...
'OutputActions', {'PA1', ['V',0,1]});
% State 2: Return to 5V (Resting)
sma = AddState(sma, 'Name', 'ReturnToFive', ...
'Timer', 1, ...
'StateChangeConditions', {'Tup', 'LickPort'}, ...
'OutputActions', {'PA1', ['V',0,0]});
sma = AddState(sma, 'Name', 'LickPort', ...
'Timer', 1, ...
'StateChangeConditions', {'Tup', 'exit'}, ...
'OutputActions', {'ValveState', 20});
%% Run State Machine
% Use BpodSystem as the first argument for Gen2
SendStateMatrix(sma);
RawEvents = RunStateMatrix();