I’m trying to create a simple learning task with pigeons where a correct peck (touch screen mouse click) results in the delivery of food. The following code allows for this action using a motor we have attached to our computers :
if mouse.isPressedIn(TargetStimulus): import maestro servo = maestro.Controller('COM4') servo.setAccel(0,4) #set servo 0 acceleration to 4 servo.setTarget(0,1200) #move servo to feed import time time.sleep(3) servo.setAccel(0,-4) #set servo 0 acceleration to -4 servo.setTarget(0,6200) #move servo to resting position servo.close
The problem is I need this action to occur consistently for 30 s, that is, for 30 s every time the pigeon pecks at the Target Stimulus, the food reward process begins. I’m not sure how to code for this as my understanding with python is that it will just read through the code from top to button, but clearly they’re must be a way to have this action continually running. Any thoughts on how to make this work would be greatly appreciated. I have had success using a textbook that says FOOD as my reward response but replacing the textbox with this bit of code is proving more difficult than I had anticipated.