ButtonBox: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 229: | Line 229: | ||
# print the button pressed | # print the button pressed | ||
print("b: {}".format(b)) | print("b: {}".format(b)) | ||
</syntaxhighlight> | |||
'''Example using markers with the buttonbox in Python:''' | |||
<syntaxhighlight lang="python" line> | |||
#!/usr/bin/env python | |||
# import the rusocsci.buttonbox module | |||
from rusocsci import buttonbox | |||
# make a buttonbox | |||
bb = buttonbox.Buttonbox() | |||
# send a marker | |||
bb.sendMarker(val=100) #This is your marker code, range code 1-255 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 250: | Line 265: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
'''Example using | '''Example using BITSI extended analog read in Python:''' | ||
<syntaxhighlight lang="python" line> | <syntaxhighlight lang="python" line> | ||
| Line 259: | Line 274: | ||
# make a buttonbox | # make a buttonbox | ||
ser = serial.Serial("COM2", 115200, timeout = 0.10 ) | |||
while True: | |||
ser.write('A1') | |||
ser.flush() | |||
x = ser.readline() | |||
visual.TextStim(win, text=x).draw() | |||
# black screen for 1000 ms | |||
win.flip() | |||
key = event.getKeys() | |||
try: | |||
if key[0]=='escape': | |||
break | |||
except: | |||
continue | |||
</syntaxhighlight> | </syntaxhighlight> | ||