Project 22: DIY Automated Cocktail Mixer

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.

How It Works

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.

Parts List

Here is everything you need to build a 3-ingredient mixer:

The Schematic

  1. Power: Connect your 12V Power Supply to the VIN and GND of the MOSFET modules.
  2. Arduino to MOSFET:
    • Connect Arduino Digital Pin 8 to the SIG pin of MOSFET 1.
    • Connect Arduino Digital Pin 9 to the SIG pin of MOSFET 2.
    • Connect Arduino Digital Pin 10 to the SIG pin of MOSFET 3.
    • Ensure the grounds are common between the Arduino and the MOSFET modules.
  3. MOSFET to Pump: Connect the Motor Out terminals (V+ and V-) on each MOSFET to the terminals on each Peristaltic Pump.
  4. Buttons: Wire three pushbuttons to Digital Pins 2, 3, and 4, utilizing the Arduino’s internal pull-up resistors.

The Code

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); 
  }
}

Assembly and Calibration

Once your electronics are wired:

  1. Cut lengths of food-grade silicone tubing and attach them to your pump inputs and outputs.
  2. Place the input tubes into bottles or jars containing your liquids.
  3. Aim all three output tubes into a single mixing glass.
  4. Calibration: Every pump is slightly different. Fill a bottle with water, turn the pump on for exactly 10 seconds, and measure how many milliliters come out. You can use this to calculate exactly how many milliseconds you need for a 1oz (30ml) shot!

Have fun, drink responsibly, and welcome to the world of fluid automation!