DIY Automatic Water Vending Machine using Arduino 16/06/2024, 01:29
Home (/) / Microcontroller Based Projects (/microcontroller-projects) / DIY Automatic Water Vending Machine using Arduino
DIY Automatic Water Vending Machine using Arduino
Published December 13, 2021 !1
Debasis Parida
Opta Expansions
(/users/debasis- (https://bit.ly/49SXcM4
parida) )
16 programmable inputs for
Author connecting digital sensors and
eight more relays to operate
machines
(https://bit.ly/49SXcM4
)
3M™ TwinAx High
Speed Cable Solutions
(https://bit.ly/455GmZx
DIYAUTOMATIC )
3M™ TwinAx High Speed Cable
WaterVending
Solutions: Thin, low profile cabl
(https://bit.ly/455GmZx with extremely tight bend radii
007
)
防钓型
Machine
Black Plated RF
Connectors and
Adapters
DIY Automatic Water Vending Machine using Arduino
(https://bit.ly/3KlNesc )
USINGARDUINO
Vending machines are very popular nowadays due to their ease of
Industrial plating option with
enhanced durability for a
variety of harsh environments
(https://bit.ly/3KlNesc )
use, multiple use cases, and no human intervention. It can dispense
products such as beverages, tickets, snacks, etc. by inserting currency G9KB Series High
coins. Vending machines appear in public and private areas such as Power PCB DC Relay
(https://bit.ly/3R5kpUL
malls, markets, offices, etc. for various applications. In this project, we
)
are going to build a Portable Drinking Water vending machine Omron's G9KB series supports
high current applications with
(https://circuitdigest.com/project/arduino-based-vending-machine) high capacity load ratings
using Arduino which can be used in any public places such as tourism
places to dispense drinking water or any other beverage using (https://bit.ly/3R5kpUL
https://circuitdigest.com/microcontroller-projects/diy-automatic-water-vending-machine-using-arduino Page 1 of 14
DIY Automatic Water Vending Machine using Arduino 16/06/2024, 01:29
Currency coins. This Vending machine uses a single Coin Acceptor )
Module that accepts the currency coins, and TRIAC
TechForum
(https://circuitdigest.com/tutorial/triac-switching-circuit-and- (https://bit.ly/4aA3WyV
applications), and Optocoupler )
Join the conversation.
(https://circuitdigest.com/tutorial/opto-coupler-types-working- TechForum is a community of
(https://bit.ly/4aA3WyV
experts on all things technical.
applications) circuitry are used to dispense the water.
)
Components Required for Building a Drinking ECX-16 32.768 KHz
Water Vending Machine: Quartz Crystal
(https://bit.ly/3Ud7KzS
Arduino UNO
)
Coin Acceptor Module The ECX-31B tuning fork crysta
(https://bit.ly/3Ud7KzS brings efficiency to mobile,
BT136 TRIAC industrial and wireless
) applications.
MOC3021 Optocoupler
Dot Matrix Perf Board RAC10E-K/277 Series
Connecting Wires AC/DC Converters
(https://bit.ly/3KlhxPP
LED RECOM Power’s 10 W AC/DC
converters in a 1.8” x 1.0” case
230V AC Water Pump
are ideal for EV charging
Pipes & Fitting (https://bit.ly/3KlhxPP )
applications
Drinking Water Vending Machine Working RM Series Aluminum
Rack Cases
(https://bit.ly/453b0D5
)
Hammond’s RM series
aluminum cases are suitable for
19” rackmount or
desktop/benchtop applications
(https://bit.ly/453b0D5
)
As shown in the block diagram above, the Coin acceptor module acts as
the input device which gives the signal to Arduino when it detects a
valid Coin inserted within it. Arduino receives the signal and gives the
https://circuitdigest.com/microcontroller-projects/diy-automatic-water-vending-machine-using-arduino Page 2 of 14
DIY Automatic Water Vending Machine using Arduino 16/06/2024, 01:29
digital command to Opto isolator which triggers the TRIAC to switch
ON/OFF the Water Pump for a specific duration. Similarly, a LED is
connected to indicate the dispensing action.
Coin Acceptor Module Working
Coin acceptor modules accept currency coins which can be suitable for
various vending machines. Coin acceptor modules are available in
multiple categories including single coin acceptor
acceptor,, comparable
type coin acceptor
acceptor,, multi-coin coin acceptor, etc. The Single coin
acceptor is specially designed to accept only a specific coin. A
comparable type of coin acceptor is used to accept the coins that are
similar to the coins put aside the coin acceptor. Multi-coin coin
acceptors can accept different coins with one machine, and output
different signals to the microcontroller. In this project, a single coin
acceptor is used.
The coin accepting device has an inbuilt microcontroller that takes data
from the sensor inside the device and collects different coins. Using
this data, the microcontroller knows whether this coin needs to be
accepted or returned. The device is easily programmed using a push-
button located on the top. The coin acceptor device gives us an impulse
signal on the output pin for every inserted coin and by counting
impulses we know how many coins have been inserted. It also has three
https://circuitdigest.com/microcontroller-projects/diy-automatic-water-vending-machine-using-arduino Page 3 of 14
DIY Automatic Water Vending Machine using Arduino 16/06/2024, 01:29
switches which we use in order to select the type of signal we want to
get on the output. The first switch has three positions to select the
impulse length. The second switch is used to set the signal to be +5
V(NC) or 0 V(NO) as shown in the figure. Using the 3rd switch, the
precision of the device can be chosen.
Training of Coin Acceptor Module
To train the Module for a specific coin, follow the steps below:
First, press the push button located on the top and hold it for 4-5
seconds until the RED LED glows up, and then release it.
While the RED LED is on, insert the coin we want to program it for.
For example, if we want to program it for 2 Rupees coins, then we
will insert only 2 Rupees coins while we program it.
https://circuitdigest.com/microcontroller-projects/diy-automatic-water-vending-machine-using-arduino Page 4 of 14
DIY Automatic Water Vending Machine using Arduino 16/06/2024, 01:29
Insert the same coin into the device 30 times in order to train the
coin to memory. After the programming is over, the LED will turn off
and the device is ready for use.
TRIAC Circuit Working
TRIAC is a three-terminal AC switch that can be triggered by a low-
energy signal at its gate terminal. In SCRs, it conducts in only one
direction, but in the case of TRIAC, the power can be controlled in both
https://circuitdigest.com/microcontroller-projects/diy-automatic-water-vending-machine-using-arduino Page 5 of 14
DIY Automatic Water Vending Machine using Arduino 16/06/2024, 01:29
directions. Here BT136 TRIAC is used for AC Pump Switch ON/OFF
purposes.
As shown in the figure above, the TRIAC is triggered at a firing angle of
90 degrees by applying a small gate pulse signal to it. The time “t1” is
the delay time which we have to give as per our application
requirement. For example, in this case, as the firing angle is 90 percent,
hence the average power output will be halved. In case we want to turn
ON the device, we need to switch it ON completely i.e t1=0.
Optocoupler
Optocoupler is also known as Optoisolator. It is used to maintain
isolation between two electrical circuits like DC and AC signals.
Basically, it consists of a LED that emits infrared light and a
photosensor that detects it. Here MOC3021 optocoupler is used to
control the AC Pump from our microcontroller signals which is a DC
signal.
Drinking Water Vending Machine Circuit
Diagram
https://circuitdigest.com/microcontroller-projects/diy-automatic-water-vending-machine-using-arduino Page 6 of 14
DIY Automatic Water Vending Machine using Arduino 16/06/2024, 01:29
ACPUMP
230VAC
GND
SIG
12V
CircuitDigest
(/fullimage?i=/circuitdiagram_mic/Drinking-Water-Vending-Machine-
Circuit-Diagram.jpg)
TRIAC and Optocoupler Connection Circuit Diagram
Programming Arduino for Vending Machine
Here we are going to program Arduino to detect the coin insertion and
coin type. Upon successful detection, it will turn on the Pump to
dispense water. Complete code is given at the end of the
document. Here, in the below lines we are explaining the important
parts of the code.
First, define the pins which are used in the hardware as shown below.
Digital Pin 2 is used as an input interrupt pin and Digital pin 6 & 12 are
used for TRIAC & LED respectively.
https://circuitdigest.com/microcontroller-projects/diy-automatic-water-vending-machine-using-arduino Page 7 of 14
DIY Automatic Water Vending Machine using Arduino 16/06/2024, 01:29
const int COIN = 2;
const int TRIAC = 6;
const int LED=12;
boolean Coin_insert = false;
int count=0;
Next, inside the setup function, an external interrupt pin will be
configured to detect the coin insertion in the device. Here a function
called attachInterrupt is used, which will configure digital Pin 2 of
Arduino as an external interrupt and it will call the function named
coinInterrupt , when it detects any interrupts at its pin.
void setup() {
Serial.begin(9600);
attachInterrupt(digitalPinToInterrupt(COIN), coinInterrupt, RISING);
pinMode(TRIAC, OUTPUT);
pinMode(LED, OUTPUT);
}
Inside Loop() , the coin insert status is checked and if it detects
successful coin insertion, then the TRIAC is triggered for a specific
duration to switch on the Pump to dispense water and after
completion, it is triggered OFF.
void loop() {
if(Coin_insert) {
digitalWrite(LED, HIGH);
delay(1000);
digitalWrite(TRIAC, HIGH);
delay(12000);
digitalWrite(TRIAC, LOW);
delay(2000);
Coin_insert = false;
}
else {
digitalWrite(LED, LOW);
digitalWrite(TRIAC, LOW);
}
}
Function coinInterrupt is called when the hardware interrupt is
detected i.e. When the coin acceptor detects a valid coin.
void coinInterrupt() {
Coin_insert = true;
}
Components Assembling and Testing
Now after connecting the components as per the circuit diagram and
programming the Arduino let’s build an enclosure like a vending
machine with a water storage tank as shown below.
https://circuitdigest.com/microcontroller-projects/diy-automatic-water-vending-machine-using-arduino Page 8 of 14
DIY Automatic Water Vending Machine using Arduino 16/06/2024, 01:29
After assembling all units in an enclosure, the setup looks like below:
The backside view of the product looks like below.
https://circuitdigest.com/microcontroller-projects/diy-automatic-water-vending-machine-using-arduino Page 9 of 14
DIY Automatic Water Vending Machine using Arduino 16/06/2024, 01:29
To Test the Arduino Vending Machine
Machine, switch ON the power supply
and place a Glass inside the tap to collect water. Now put a 2 rupees
coin inside the acceptor. Once it detects the coin the Green LED should
glow and water dispensing should start. Once the glass is filled, the LED
and pump should turn OFF.
This is how you can build a Drinking Water Vending Machine
Arduino and Coin Acceptor module. If you have any questions or
suggestions, you can put them in the comment section or can use our
forum (https://circuitdigest.com/forums).
Code
Coin_Acceptor.ino
https://circuitdigest.com/microcontroller-projects/diy-automatic-water-vending-machine-using-arduino Page 10 of 14
DIY Automatic Water Vending Machine using Arduino 16/06/2024, 01:29
const int COIN = 2;
const int TRIAC = 6;
const int LED=12;
boolean Coin_insert = false;
int count=0;
void setup()
{
Serial.begin(9600);
attachInterrupt(digitalPinToInterrupt(COIN), coinInterrupt, RI
SING);
pinMode(TRIAC, OUTPUT);
pinMode(LED, OUTPUT);
}
void loop()
{
if(Coin_insert)
Video
How to Make an Automatic Water Vending Machine using …
Tags
Arduino (/Tags/Arduino) Arduino Uno (/Tags/Arduino-Uno)
Vending Machine (/Tags/Vending-Machine)
Coin Acceptor Module (/Tags/Coin-Acceptor-Module)
Have any question realated to this Article?
Ask Our Community Members
WHATSAPP
(Https://Chat.whatsapp.com/JR4e0Fc0V20H6jTMDd1daT)
TELEGRAM
(Https://T.me/Circuitdigest)
https://circuitdigest.com/microcontroller-projects/diy-automatic-water-vending-machine-using-arduino Page 11 of 14
DIY Automatic Water Vending Machine using Arduino 16/06/2024, 01:29
DISCORD
(Https://Discord.com/Invite/UXJrFJSWpz)
FORUM
(Https://Circuitdigest.com/Forums)
Comments
Submitted by Beast (/users/zxcesler) on Fri, 11/18/2022 - 11:42
Permalink (/comment/35806#comment-35806)
I really love this Project,…
(/comment/35806#comment-35806)
I really love this Project, please can i have more images on how you
made this? i wanted to make this for my School Project. i would ve very
grateful if you give me more tutorials for this project, Thank you.
Log in (/user/login?destination=/microcontroller-projects/diy-
automatic-water-vending-machine-using-arduino%23comment-form)
or register (/user/register?destination=/microcontroller-projects/diy-
automatic-water-vending-machine-using-arduino%23comment-form)
to post comments
Join 100K+ Subscribers
Your email is safe with us, we don’t spam.
https://circuitdigest.com/microcontroller-projects/diy-automatic-water-vending-machine-using-arduino Page 12 of 14
DIY Automatic Water Vending Machine using Arduino 16/06/2024, 01:29
Type your email address Subscribe
Be a part of our ever growing community.
COMPANY Privacy Policy (/privacy-policy) Cookie Policy
(/cookie-policy) Terms of Use (/terms-of-
use) Contact Us (/contact) Advertise
Semicon Media is a unique (/advertise)
collection of online media, focused
purely on the Electronics
Community across the globe. With PROJECT 555 Timer Circuits (/555-timer-circuits) Op-
a perfectly blended team of amp Circuits (/op-amp-circuits) Audio Circuits
Engineers and Journalists, we
(/audio-circuits) Power Supply Circuits (/smps-
demystify electronics and its
power-supply-circuits) Arduino Projects
related technologies by providing
high value content to our readers. (/arduino-projects) Raspberry Pi Projects
(/simple-raspberry-pi-projects-for-beginners)
MSP430 Projects (/msp430-projects) STM32
(https://www.facebook.com/circuitdigest/)
Projects (/stm32-projects-and-tutorials)
(https://twitter.com/CircuitDigest) ESP8266 Projects (/esp8266-projects) PIC
Projects (/pic-microcontroller-projects) AVR
(https://www.youtube.com/channel/UCy3CUAIYgZdAOG9k3IPdLmw)
Projects (/avr-microcontroller-projects) 8051
(https://www.linkedin.com/company/circuit- Projects (/8051-microcontroller-projects)
digest/) ESP32 Projects (/esp32-projects) IoT Projects
(/internet-of-things-iot-projects) PCB Projects
(/diy-pcb-projects) Arduino ESP8266 Projects
(/arduino-esp8266-projects) All
Microcontroller Projects (/microcontroller-
projects)
https://circuitdigest.com/microcontroller-projects/diy-automatic-water-vending-machine-using-arduino Page 13 of 14
DIY Automatic Water Vending Machine using Arduino 16/06/2024, 01:29
OUR
NETWORK
(https://circuitdigest.com)
(https://components101.com)
(https://iotdesignpro.com)
Copyright © 2023 Circuit Digest (/). All rights reserved.
https://circuitdigest.com/microcontroller-projects/diy-automatic-water-vending-machine-using-arduino Page 14 of 14