Exp 01: An experiment with a Fed3 - fdechaumont/micecraft GitHub Wiki
Here is our first experiment: we just want our fed to deliver a pellet and emit a click each time an animal is nose poking.
You just need a few lines to do this:
from micecraft.devices.fed3.Fed3 import Fed3
if __name__ == '__main__':
def listener( event ): # this is this function that will receive the events from your device
if "nose poke" in event.description: # here we check what the description of the event contains.
fed.click() # the fed emits a click
fed.feed() # the fed starts the feeding action
fed = Fed3( comPort="COM78", name="Fed3" ) # we create our fed controller
fed.addDeviceListener(listener) # add our listener (callback) to our listener function to receive events from the device
input("hit enter to stop experiment.") # wait for user
fed.shutdown() # stop the fed for a clean exit