# initial state sma.add_state( state_name="start", state_timer=5, state_change_conditions={"Tup": "reward"}, output_actions=[("BNC1", 1)], ) # open valve1 for 20 seconds sma.add_state( state_name="reward", # output action will be performed for whole time state is active state_timer=20, state_change_conditions={"Tup": "exit"}, # output action for valve open = 255 # notation for valve alsways Valve + numer of port connected to output_actions=[("Valve1", 255)], ) bpod.send_state_machine(sma) # Run state machine if not bpod.run_state_machine( sma): # Locks until state machine 'exit' is reached break print("Current trial info: {0}".format(bpod.session.current_trial)) bpod.close()
output_actions=[('Valve', 2)]) sma.add_state(state_name='wait2', state_timer=waittime, state_change_conditions={EventName.Tup: 'Open Middle'}, output_actions=[]) sma.add_state(state_name='Open Middle', state_timer=ValveOpenTime_M, state_change_conditions={EventName.Tup: 'wait3'}, output_actions=[('Valve', 3)]) sma.add_state(state_name='wait3', state_timer=waittime, state_change_conditions={EventName.Tup: 'Close Valves'}, output_actions=[]) if i == 0: sma.add_state(state_name='Close Valves', state_timer=ValveCloseTime, state_change_conditions={EventName.Tup: 'exit'}, output_actions=[(OutputChannel.PWM3, 255)]) # else: sma.add_state(state_name='Close Valves', state_timer=ValveCloseTime, state_change_conditions={EventName.Tup: 'exit'}, output_actions=[]) my_bpod.send_state_machine( sma) # Send state machine description to Bpod device my_bpod.run_state_machine(sma) # Run state machine my_bpod.close()