Brains and Dr. Brawn

The Operant Training Cage


The Operant Training Cage is an automated cage designed for operantly training rats on auditory-spatial learning tasks. Each side of the cage is fitted with: 1) a response port where rats can initiate and respond to trials via infrared sensors, and 2) a syringe pump for dispensing liquid reward. A single USB speaker for playback of auditory stimuli is placed inside at the top of the cage. Each response port module is controlled by an Arduino stack. The operant training procedures are written in Python.

Below you will find step-by-step instructions for how to build the operant training cage, the Arduino and Python code I code use to run various shaping and training procedures, and links to the materials needed to construct the operant cage and electronics.

Assembly Instructions

Click on the pictures or links below to download assembly instructions for each part of the operant cage:

Proto Screw Shield

1. Construct the Proto Screw Shield

Electronics Assembly Instructions

2. Assemble the response port module electronics

Response Port Assembly Instructions

3. Connect the electronics to the response port

Syringe Pump Assembly Instructions

4. Assemble the syringe pump

A+ Maze Assembly Instructions

5. Construct the Operant Training Cage

Operant Training Source Code

Shape01: 4-Port Single Response Trials: All four response ports are active (indicated by LED) during Shape01. The rat can probe any of the ports and receive a reward. The port becomes inactive for 30s following a response. You can set the maximum number of trials allowed for each port. The port will become inactive after reaching the trial maximum. The session ends when the trial maxmimum has been reached at each port. The same arduino file is uploaded to all four arduinos.

Python Shape01

Download Shape01 Python Code

Arduino Shape01

Download Shape01 Arduino Code

Shape02: 1-port Single Response Trials: A single response port is randomly selected and becomes active (indicated by LED) during Shape02. The rat must probe the active port to receive a reward. After the trial is completed, one of the other 3 ports is randomly selected and becomes active. The session ends when the rat has completed the user-set maximum number of trials. A different arduino file is uploaded to each of the four ports (North, East, South, West).

Python Shape02

Download Shape02 Python Code

Arduino Shape02-North

Download Shape02-North Arduino Code

Arduino Shape02-East

Download Shape02-East Arduino Code

Arduino Shape02-South

Download Shape02-South Arduino Code

Arduino Shape02-West

Download Shape02-West Arduino Code

Shape03: 2-port Double Response Trials: During Shape03, the north or south port is randomly selected as the trial initiation port and becomes active. When the rat probes the active initiation port, the east or west port becomes active as the trial response port. The user can set the response window duration for how long the rat can take to probe the response port after probing the initiation port before the trial resets. A different arduino file is uploaded to each of the four ports (North, East, South, West).

Python Shape03

Download Shape03 Python Code

Arduino Shape03-North

Download Shape03-North Arduino Code

Arduino Shape03-East

Download Shape03-East Arduino Code

Arduino Shape03-South

Download Shape03-South Arduino Code

Arduino Shape03-West

Download Shape03-West Arduino Code

2AC auditory-spatial classification task: In the 2-alternative choice auditory-spatial classification task, the north or south port is randomly selected as the trial initiation port and becomes active. When the rat probes the active initiation port, one of two sound stimuli is played back by the speaker above the port, and the east and west ports become active. The sound indicates the location of the reward. If the rat probes the correct response port, reward is dispensed, the auditory stimulus is replayed, and a trial initiation port is selected randomly again. If the rat probes the wrong port, an error sound is played back and a new trial will begin after a timeout period. If the rat does not respond to the stimuli within the response window, the trial ends and a new trial will begin after a timeout period. A different arduino file is uploaded to each of the four ports (North, East, South, West).

Python 2AC

Download 2AC Python Code

Arduino 2AC-North

Download 2AC-North Arduino Code

Arduino 2AC-East

Download 2AC-East Arduino Code

Arduino 2AC-South

Download 2AC-South Arduino Code

Arduino 2AC-West

Download 2AC-West Arduino Code

Syringe Pump Control: Syringe Pump Control is an arduino file that allows you to move the Syringe Pump in the forward or reverse direction in increments of 1K, 5K, 10K, or 25K microsteps via the Serial Monitor.

Arduino Syringe Pump Control

Download Syringe Pump Control Arduino Code

Bill of Materials

Operant Cage
Part Price Quantity Notes
Rodent Cage ? 1 Any acceptable cage should work
3D Print: OpCage Window Attachment $19* 4 One attachment for each of the response port windows
80-20 Bolt Assembly (25 pack) $12.77 4 Connectors for window attachments and rails
Part #4113 Wide Inside Corner Bracket $4.05 12 Connects rails to other rails or corrugated plastic
Part #S-14371BL: 24" x 18" Plastic Corrugated Pad (10 pack) $32 1 One is attached to foam block at the end of each arm
JLab USB Speaker $22.00 1 attached to top of cage


Response Port Module
Part Price Quantity Notes
3D Print: Response Port Housing $43* 4 One response port module for each arm of the maze
3D Print: Electronics Tray $72** 4 One tray for each arduino stack
Elegoo UNO R3 (Arduino) $11.86 4 One arduino for each response port module
Proto Screwshield R3 Kit $14.95 4 Arduino shield for the LED and IR circuitry. One screwshield for each response port module
IR Beam Break Sensor (3mm) $1.95 4 One for each response port module
3mm LEDs (1000 pack) $14.99 1 One for each response port module
7-port USB Hub $28.99 2 This hub connects to the maze's 4 arduinos and 4 usb speakers
Hook-Up Wire $13.99 1 Used to wire LEDs and connect stepper motor to driver
USB extension cables: 3ft (2 pack) $9.99 2 Connects arduinos to USB hubs
Part #1020: 1" x 2" T-Slotted Rail (length = 9") $5.46 4 Response port and electronics attach to these rails
Part #1020: 1" x 2" T-Slotted Rail (length = 3") $2.34 4 Response port and electronics attach to these rails


Syringe Pump
Part Price Quantity Notes
3D Print: Syringe Pump Part 1*** $20* 4 Attaches to stepper motor
3D Print: Syringe Pump Part 2*** $15* 4 Holds the plunger flange
3D Print: Syringe Pump Part 3*** $15* 4 Holds the barrel flange
3D Print: Syringe Pump Part 4*** $15* 4 Holds the syringe tip
Stepper Motor $15.99 4 One for each syringe pump
Stepper Motor Driver $12.00 4 One for each arduino stack
5mm to 8mm Rigid Stepper Motor Shaft Coupler $3.34 4 Connects the stepper motor to the lead screw.
M8 stainless steel threaded rod: 1m $15.76 1 Syringe pump lead screw
8mm Linear Shaft (2 pack) $11.59 2 Runs through linear bearing and Syringe Pump Parts
8mm Linear bearing (10 pack) $9.03 1 Connects to linear shaft and Syringe Pump Part 2
M3 screw kit $9.99 1 Connects stepper motor to Syringe Pump Part 1
30ml Luer Lock Syringe (10 pack) $19.99 1 Other syringe sizes also work
M8 Hex Nut (50 pack) $13.38 1 Fits in syringe pump part 2
Female Luer Lock 1/8" Adapter (25 pack) $10.25 1 Connects syringe to tubing
Nickel-Plated Brass Male Luer Lock 1/8" Adapter $23.00 4 Attaches to tubing to dispense reward
Plastic Tubing (100ft) $11.44 1 Connects to male and female luer lock components
1" x 2" T-Slotted Rail (Part# 1020): 12" $6.63 4 Syringe pump parts are attached to this rail

* Price varies depending on 3D-printing company and material used. I typically use i.materialise or Shapeways for printing

** The quality of the tray isn't very important and any tray that can hold the arduino stack will do.

*** These stl files were downloaded from a hackaday blog that is no longer active