-
Notifications
You must be signed in to change notification settings - Fork 18
1. Getting started
This page will help you get started writing your first custom FED3 behavioral program! Scripts should be written in the Arduino IDE and flashed to FED3 through the microUSB port. This page will walk you through an annotated version of a simple Fixed-Ratio 1 Example that will describe the parts of a FED3 script.
Start your script 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
}
}
This complete FR1 script can be copy/pasted into the Arduino IDE and flashed to the FED3. Just make sure to have the FED3 library and its dependent libraries installed!
#include <FED3.h> //Include the FED3 library
String sketch = "FR1"; //Unique identifier text for each sketch
FED3 fed3 (sketch); //Start the FED3 object
void setup() {
fed3.begin(); //Setup the FED3 hardware
}
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();
}
}