A liquid dispenser comprising: a housing ; a reservoir configured to store a liquid; a flexible tube disposed in the housing, wherein the flexible tube has an inlet and an outlet; a pump disposed in the housing , the pump being a peristaltic pump, being positioned near the top of the dispenser , and being configured to drive discrete volumes of a known amount, wherein the pump comprises: a rotor including a plurality of rollers , wherein the rotor has a rotor rotational axis, wherein each of the plurality of rollers has a roller rotational axis, and wherein each of the plurality of rollers is configured to rotate about the rotor rotational axis and its respective roller rotational axis, wherein each of the plurality of rollers is configured to contact the flexible tube such that each of the plurality of rollers compresses a portion of the flexible tube that is in contact with the roller ; a motor disposed in the housing , wherein the motor is configured to drive the pump to cause the liquid to move through the flexible tube ; a first sensor configured to generate a signal based on a distance between an object and the first sensor ; and an electronic processor configured to receive the signal from the first sensor and to determine a dispensation volume of the liquid, the dispensation volume varying as a function of the distance between the object and the first sensor , the processor further configured to control the motor to dispense the dispensation volume of the liquid by controlling the number of rotations of the rotor , wherein the number of rotations of the rotor corresponds to the dispensation volume of the liquid. a housing ; a reservoir configured to store a liquid; a flexible tube disposed in the housing, wherein the flexible tube has an inlet and an outlet; a pump disposed in the housing , the pump being a peristaltic pump, being positioned near the top of the dispenser , and being configured to drive discrete volumes of a known amount, wherein the pump comprises: a rotor including a plurality of rollers , wherein the rotor has a rotor rotational axis, wherein each of the plurality of rollers has a roller rotational axis, and wherein each of the plurality of rollers is configured to rotate about the rotor rotational axis and its respective roller rotational axis, wherein each of the plurality of rollers is configured to contact the flexible tube such that each of the plurality of rollers compresses a portion of the flexible tube that is in contact with the roller ; a rotor including a plurality of rollers , wherein the rotor has a rotor rotational axis, wherein each of the plurality of rollers has a roller rotational axis, and wherein each of the plurality of rollers is configured to rotate about the rotor rotational axis and its respective roller rotational axis, wherein each of the plurality of rollers is configured to contact the flexible tube such that each of the plurality of rollers compresses a portion of the flexible tube that is in contact with the roller ; a motor disposed in the housing , wherein the motor is configured to drive the pump to cause the liquid to move through the flexible tube ; a first sensor configured to generate a signal based on a distance between an object and the first sensor ; and an electronic processor configured to receive the signal from the first sensor and to determine a dispensation volume of the liquid, the dispensation volume varying as a function of the distance between the object and the first sensor , the processor further configured to control the motor to dispense the dispensation volume of the liquid by controlling the number of rotations of the rotor , wherein the number of rotations of the rotor corresponds to the dispensation volume of the liquid. <EOS>