A feeder comprising: a feed container having a volume for holding feed, a feed input part for providing a feed input into the feed container, a feed valve which is connected to the feed input part and the feed container, wherein the feed valve is configured to regulate and control the flow of feed into the feed container, a dosing valve which is connected to the feed container and controls and regulates the flow of feed out of the container, a first feed sensor which is configured to provide a first parameter representing an amount of feed inside the feed container, where the feed valve and/or the dosing valve are configured to be controlled by a control signal that is at least partly based on the first parameter.