% Assuming your valve is connected to Port 1 and the reward valve time is 0.05s
sma = NewStateMachine();
sma = AddState(sma, 'Name', 'TTL', ...
'Timer', 0.001,...
'StateChangeConditions', {'Tup', 'WaitFiveSeconds'},...
'OutputActions', {'BNC1', 1});
sma = AddState(sma, 'Name', 'WaitFiveSeconds', ...
'Timer', 5,...
'StateChangeConditions', {'Tup', 'Reward'},...
'OutputActions', {});
sma = AddState(sma, 'Name', 'Reward', ...
'Timer', 0.05,...
'StateChangeConditions', {'Tup', 'WaitForLicking'},...
'OutputActions', {});
sma = AddState(sma, 'Name', 'WaitForLicking', ...
'Timer', 2,...
'StateChangeConditions', {'Tup', '>exit'},...
'OutputActions', {});
% Send to the state machine device
SendStateMachine(sma);
% Run the state machine
RawEvents = RunStateMachine();
This should do it.