Hello,
I am new to working on the FED machines and was hoping you could help. We are ultimately trying to get to the go/no-go task, but right now I am trying to write a code to make the animals do the following as one of our steps to getting there:
The animal pokes the left hole, a low pitch sound plays, and if the animal keeps their nose in the hole for 0.6 seconds (our goal time), a high pitch sound plays to release them for their treat. If they release before the 0.6 seconds they receive the click, no second tone, and no reward.
I have the following code:
void loop() {
fed3.run(); //Call fed.run at least once per loop
if (fed3.Left) { //If left poke is triggered
fed3.Tone(50, 500); //Play low pitch sound
fed3.logLeftPoke(); //Log left poke
if (millis() >= fed3.minPokeTime) { //if # msec is >= min poke time (0.6 seconds)
fed3.Tone(2500, 500); //play high pitch tone (release)
fed3.Feed();
}
else {
fed3.Click(); //Otherwise, no reward or second sound
}
if (fed3.Right) { //If right poke is triggered
fed3.logRightPoke(); //Log right poke
}
}
}
This waits for the animal to remove their nose before the
second tone plays. Do you know if there is a way to have the time initiate
the second tone as soon as the nose poke gets to 0.6 seconds? I know the millis() function is our problem, but we can't find a way to make the poke time register before the animal removes their nose.
Thanks in advance!
Lydia
Hi! Thanks for the response.
I had this originally, in the FED3.h it defines
fed3.leftinterval as what you wrote above. The issue when I do this is that it
waits for the animal to remove their nose before it can register the
leftpoketime. I was hoping to get it to work as a counter so as soon as the
poke reached a certain time, it would cause the sound, instead of waiting for
them to remove their nose. Ideally, we want the high-pitched sound to be used
as a trigger that indicates they have reached the required time and can now go
get their food.
Thanks!
Lydia