🧃 Build Your Own Arduino Juice Vending Machine!
Press a button, pick your flavor, and watch real juice pour into your cup — all controlled by an Arduino, a tiny water pump, and a few push buttons. A perfect mini vending machine for your room or next school fair!
What You'll Build
A mini vending machine that pours juice into a cup when you press a flavor button. An Arduino Uno reads the button presses and turns on a small submersible water pump for a few seconds — just enough to fill a cup — using a relay or transistor to safely control the pump's power.
🎯 Why Kids Love This Robotics Project
This is one of the most exciting Arduino robotics projects for kids because it actually does something useful and tasty! It teaches real-world ideas like input (buttons), output (pumps), and timing (how long to pour) — all while building a machine you can show off and actually use at parties.
🧰 Materials You Need
⚠️ Adult Supervision Needed
This project involves electrical wiring near liquids. Always keep wires, the Arduino, and any non-waterproof parts away from spills, and have an adult help with wiring and testing the pumps.
🛠️ Step-by-Step Building Instructions
Build the Machine Body
Cut a sturdy cardboard box into a vending machine shape, with a small open shelf at the bottom where the cup will sit, and a front panel for the buttons.
Set Up the Juice Bottles
Place each juice bottle upright inside the machine, with one submersible pump sitting inside each bottle, fully covered by juice.
Connect the Tubing
Attach a length of silicone tubing to each pump's outlet, running it down to a spout positioned above where the cup will sit.
Mount the Buttons
Fix one push button on the front panel for each flavor, labeled clearly (e.g., "Orange," "Berry," "Lemon") so it feels like a real vending machine.
Wire the Relays
Connect each pump to its own relay module, which acts as a safe switch the Arduino can control. Wire each relay's control pin to a different Arduino digital pin.
Wire the Buttons
Connect each push button to its own Arduino digital input pin, following the circuit diagram below.
Upload the Code
Copy the code below into the Arduino IDE and upload it. Each button should now trigger its matching pump for a few seconds.
Test with Water First
Before using real juice, test the whole system with plain water to check tubing, timing, and cup placement — then swap in juice once everything works smoothly!
🔌 Circuit Diagram
Layout (shown for one flavor — repeat per pump):
ARDUINO UNO RELAY MODULE
┌───────────────┐ ┌─────────────┐
│ 5V ●─────────┼──────────┤ VCC │
│ GND ●─────────┼──────────┤ GND │
│ Pin 7●─────────┼──────────┤ IN │
│ │ │ COM ●────┬───┼── External 5V (+)
│ │ │ NO ●────┼───┼── Pump (+)
└───────────────┘ └──────────┼───┴── Pump (-) ── External GND
│
BUTTON: Pin 2 ──[Button]── GND (using INPUT_PULLUP)
| Component | Wire | Arduino Pin |
|---|---|---|
| Flavor 1 Button | One leg | Pin 2 (other leg to GND) |
| Flavor 2 Button | One leg | Pin 3 (other leg to GND) |
| Flavor 3 Button | One leg | Pin 4 (other leg to GND) |
| Relay 1 (Pump 1) | IN signal | Pin 7 |
| Relay 2 (Pump 2) | IN signal | Pin 8 |
| Relay 3 (Pump 3) | IN signal | Pin 9 |
Tip: Power the pumps from a separate 5V supply (not directly from the Arduino), and only let the relay switch that external power — this keeps your Arduino safe from pump power spikes.
💻 Arduino Code
juice_vending_machine.ino// ---- Pin Setup ----
const int buttonPins[3] = {2, 3, 4}; // Orange, Berry, Lemon
const int relayPins[3] = {7, 8, 9}; // Matching pumps
const unsigned long pourTime = 3000; // 3 seconds per cup (adjust to taste!)
void setup() {
for (int i = 0; i < 3; i++) {
pinMode(buttonPins[i], INPUT_PULLUP); // button connects pin to GND when pressed
pinMode(relayPins[i], OUTPUT);
digitalWrite(relayPins[i], LOW); // make sure pumps start OFF
}
Serial.begin(9600);
Serial.println("Juice machine ready! Pick a flavor.");
}
void pourFlavor(int index, String name) {
Serial.print("Pouring: ");
Serial.println(name);
digitalWrite(relayPins[index], HIGH); // turn pump ON
delay(pourTime);
digitalWrite(relayPins[index], LOW); // turn pump OFF
Serial.println("Enjoy your juice!");
}
void loop() {
if (digitalRead(buttonPins[0]) == LOW) {
pourFlavor(0, "Orange");
delay(1000); // tiny pause to avoid double-presses
}
if (digitalRead(buttonPins[1]) == LOW) {
pourFlavor(1, "Berry");
delay(1000);
}
if (digitalRead(buttonPins[2]) == LOW) {
pourFlavor(2, "Lemon");
delay(1000);
}
}
pourTime), then switches it off — pouring just the right amount of juice every time!
🌟 Tips for a Better Juice Machine
- Start with water tests to find the perfect
pourTimefor a full cup without overflowing. - Use a drip tray under the spouts to catch any extra drops and keep things tidy.
- Label each button with the flavor name and a fun sticker or drawing.
- Clean the tubing and pumps regularly if using real juice, since sugary drinks can get sticky.
- Add a "Thank You!" message on a small LCD or just print it to the Serial Monitor for now.
❓ Frequently Asked Questions
Do I need to know how to code to build this?
No! The code above is ready to copy and upload. You can adjust the pourTime value to change how much juice is poured.
Can I add more flavors?
Yes! Just add more entries to the buttonPins and relayPins arrays and connect more buttons, relays, and pumps following the same pattern.
Is it safe to use real juice with electronics nearby?
With careful wiring, keeping electronics away from spills, and adult supervision, this project is safe — but always test with water first and never let liquid touch the Arduino or relays.
What age group is this project good for?
With an adult's help for wiring and testing, kids aged 10 and up can enjoy building and using this fun vending machine.
🏆 You Did It!
You just built a real working juice vending machine! Try adding an LCD screen to show flavor names, a coin slot for pretend payments, or even a cup sensor so it only pours when a cup is in place.

Comments
Post a Comment