Skip to content

1. Getting started

Kravitz Lab edited this page Dec 30, 2020 · 7 revisions

This page will help you get started writing your first custom FED3 behavioral program!

Below is an annotation of the Fixed-Ratio 1 Example at the bottom of this page to describe how to write a new FED3 script. Start with this small block of code to import the FED3 library, name your sketch (here it is "FR1"), and start the FED3 object. The only thing you'll edit here is the text "FR1", which should be set to a unique String of text to identify your sketch. This text will show up in the logfile in the column "LibaryVersion_Sketch".

#include <FED3.h>                                       //Include the FED3 library 
String sketch = "FR1";                                  //Unique identifier text for each sketch
FED3 fed3 (sketch);                                     //Start the FED3 object

In "void setup()" the function fed3.begin() initializes all of the FED3 hardware and gets it ready to use. Don't edit this part.

void setup() {
  fed3.begin();                                         //FED3 hardware setup commands
}

Finally, "void loop()" is where you will write your behavioral program. Make sure to include the function fed3.run() at the top of the loop. fed3.run() updates the display and handles processor sleep modes. Define what happens when the mouse pokes left (fed3.Left), or right (fed3.Right) under the if statements for each. Variables and functions that FED3 can use to make programs are listed below.

void loop() {
  fed3.run();                                           //Call fed.run at least once per loop

  if (fed3.Left) {                                      //If left poke is triggered
    fed3.logLeftPoke();                                 //Log left poke
    fed3.ConditionedStimulus();                         //Deliver conditioned stimulus (tone and lights)
    fed3.Feed();                                        //Deliver pellet
  }
  
  if (fed3.Right) {                                     //If right poke is triggered
    fed3.logRightPoke();                                //Log right poke
  }
}
Clone this wiki locally