-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvalve.py
44 lines (31 loc) · 1 KB
/
valve.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from pybpodapi.bpod import Bpod
from pybpodapi.state_machine import StateMachine
bpod = Bpod()
trials = 10
iti = 2
for trial in range(trials):
# send ttl to bnc1
sma = StateMachine(bpod)
# 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()