Vending Machine For Water and Beverages



Whether for quenching your thirst with water or for simply having fun while consuming soft drinks, daily liquid consumption is an essential part of our lives.To obtain a bottle of water or soft drink, you would normally visit a shop and purchase it from the seller. But in this time of the pandemic, you have to be cautious regarding people you come in contact with; you don’t want to contract the virus or spread it. So should you stop consuming liquid from outdoors altogether? No. There is a solution to this problem.

Today you will learn how to make a smart vending machine that offers your desired drink such as a soft drink, coffee, water etc. And since there isn’t any human involvement, you are at no risk of contracting the virus.For operating the vending machine, you will use a coin acceptor and solenoid valve connected with an Arduino. While the coin acceptor will check the value of the inserted coin, the Arduino will process the entered data and perform the relevant liquid dispensing.

Bill Of Materials

Teaching The Coin Acceptor

Before proceeding with the vending machine’s operating details, the coin acceptor needs to recognise the difference between a duplicate and a valid coin so that it can correctly provide the drink of your choice.

Attached to the coin acceptor are 4 wires: red (12V), black (GND) yellow (coin data) and white (counter data). Press the button on top of the coin acceptor for supplying 12V, until the red LED turns on. Insert a Rs 5 coin to turn off the red LED. The coin acceptor will recognise its validity and accept it.


You can 3D print or order from any online 3D printing service to have a vending machine as per your design preferences. Here, the vending machine has been designed in two parts: one for accepting the coin and another for offering the liquid. There are two holes at the side for passing the pipe and TOF sensor wires (to check the level of water poured into the drinking glass).


The programming code required for the vending machine will process the signal from the coin acceptor and send it to the relay module for turning ON the solenoid valve for dispensing the liquid. At the same time, the feedback from the TOF sensor will help estimate the level at which a drinking glass gets filled. The solenoid valve stops when the glass is full.

Define the pin for the interrupt of the coin pulse and create a setup function that checks the connection with the TOF sensor and starts the serial port for debugging. Next, create a loop for the solenoid valve when the correct coin is detected. It will check the liquid level in the glass and stop the valve when the required level gets achieved.

Leave A Reply

Your email address will not be published.