Want to build the ultimate party trick? Today we are building an automated cocktail (or mocktail) mixer! Because manually pouring liquids is for peasants. By pressing a single button, your Arduino will trigger pumps to draw exact amounts of liquids into your glass. This project is a fantastic introduction to peristaltic pumps and the very real danger of spilling sticky juice all over your expensive electronics.
We’ll be using peristaltic pumps. Unlike regular water pumps, these work by having a motor squeeze a flexible silicone tube in a circular motion. This means the liquid only ever touches the inside of the tube, never the motor itself—making it food-safe and easy to clean!
Since these pumps require 12V and pull more current than the Arduino can provide, we use MOSFET modules (specifically the IRF520) to act as heavy-duty electronic switches. The Arduino sends a tiny 5V signal to the MOSFET, which opens the floodgates for the 12V power supply to run the pump.
Here is everything you need to build a 3-ingredient mixer:
VIN and GND of the MOSFET modules.SIG pin of MOSFET 1.SIG pin of MOSFET 2.SIG pin of MOSFET 3.V+ and V-) on each MOSFET to the terminals on each Peristaltic Pump.Here is the logic to pour three different recipes depending on which button is pressed. We use a simple time-based pouring method. Since peristaltic pumps push a consistent volume of liquid per second, timing the pump translates directly to milliliters!
// Pump Control Pins
const int PUMP_1 = 8;
const int PUMP_2 = 9;
const int PUMP_3 = 10;
// Button Pins
const int BTN_RECIPE_1 = 2;
const int BTN_RECIPE_2 = 3;
const int BTN_RECIPE_3 = 4;
void setup() {
// Set pump pins as outputs
pinMode(PUMP_1, OUTPUT);
pinMode(PUMP_2, OUTPUT);
pinMode(PUMP_3, OUTPUT);
// Set button pins as inputs with pullup resistors
pinMode(BTN_RECIPE_1, INPUT_PULLUP);
pinMode(BTN_RECIPE_2, INPUT_PULLUP);
pinMode(BTN_RECIPE_3, INPUT_PULLUP);
}
void pourLiquid(int pumpPin, unsigned long milliseconds) {
digitalWrite(pumpPin, HIGH); // Turn pump on
delay(milliseconds); // Wait for the liquid to pour
digitalWrite(pumpPin, LOW); // Turn pump off
}
void loop() {
// Recipe 1: 50% Pump 1, 50% Pump 2
if (digitalRead(BTN_RECIPE_1) == LOW) {
pourLiquid(PUMP_1, 5000); // Pour for 5 seconds
pourLiquid(PUMP_2, 5000); // Pour for 5 seconds
delay(1000); // Debounce delay
}
// Recipe 2: 70% Pump 2, 30% Pump 3
if (digitalRead(BTN_RECIPE_2) == LOW) {
pourLiquid(PUMP_2, 7000);
pourLiquid(PUMP_3, 3000);
delay(1000);
}
// Recipe 3: 33% of all three
if (digitalRead(BTN_RECIPE_3) == LOW) {
pourLiquid(PUMP_1, 3000);
pourLiquid(PUMP_2, 3000);
pourLiquid(PUMP_3, 3000);
delay(1000);
}
}
Once your electronics are wired:
Have fun, drink responsibly, and welcome to the world of fluid automation!