Supported by Supported by

SR Box

About the srbox plugin

The serial response (SR) box is a button box, specifically designed for response collection in psychological experiments. The original version, developed by Psychology Software Tools, has 5 buttons, 5 lights, and is connected to the PC trough the serial port. There are also SR Box compatible devices by other manufacturers, which may differ in the number of buttons and lights and often use a USB connection, which emulates a serial port.

The srbox plugin for OpenSesame allows you to use the SR Box or compatible device in your OpenSesame experiments.



Figure 1. The srbox plugin in OpenSesame.

Setting the device name

By default, the plugin tries to autodetect your SR Box. If this works, you don't have to change it. If your experiment freezes, OpenSesame has chosen the wrong serial port and you must enter the device name manually. Under Windows, the device is probably called something like


Under Linux the device is probably called something like



An SR Box or compatible button box. Not all button boxes are compatible, see:

Using the SR Box from Python inline code

class srbox

If you insert the srbox plugin at the start of your experiment, an instance of srbox automatically becomes part of the experiment object and can be accessed within an inline_script item as srbox.

Important note 1:

If you do not specify a device, the plug-in will try to autodetect the SR Box port. However, on some systems this freezes the experiment, so it is better to explicitly specify a device.

Important note 2:

You need to call srbox.start to put the SR Box in sending mode, before calling srbox.get_button_press to collect a button press.


t0 = clock.time()
button, t1 = srbox.get_button_press(allowed_buttons=[1,2],
if button == 1:
        response_time = t1 - t0
        print('Button 1 was pressed in %d ms!' % response_time)

function srbox.__init__(experiment, dev=None)

Constructor. An srbox object is created automatically by the srbox plug-in, and you do not generally need to call the constructor yourself.


  • experiment -- An Opensesame experiment.
    • Type: experiment


function srbox.close()

Closes the connection to the srbox. This is done automatically by the srbox plugin when the experiment finishes.

function srbox.get_button_press(allowed_buttons=None, timeout=None, require_state_change=False)

Collects a button press from the SR box.


  • allowed_buttons -- A list of buttons that are accepted or None to accept all buttons. Valid buttons are integers 1 through 8.
    • Type: list, NoneType
    • Default: None
  • timeout -- A timeout value in milliseconds or None for no timeout.
    • Type: int, float, NoneType
    • Default: None
  • require_state_change -- Indicates whether already pressed button should be accepted (False), or whether only a state change from unpressed to pressed is accepted (True).
    • Default: False


A button_list, timestamp tuple. button_list is None if no button was pressed (i.e. a timeout occurred).

  • Type: tuple

function srbox.send(ch)

Sends a single character to the SR Box. Send '`' to turn off all lights, 'a' for light 1 on, 'b' for light 2 on,'c' for lights 1 and 2 on etc.


  • ch -- The character to send.
    • Type: str

function srbox.start()

Turns on sending mode, so that the SR Box starts to send output. The SR Box must be in sending mode when you call srbox.get_button_press.

function srbox.stop()

Turns off sending mode, so that the SR Box stops giving output.