How to Build a Portable Drinking Water Vending Machine Using Arduino

Publisher:MengyunLatest update time:2023-06-06 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Nowadays, vending machines are very popular because of their ease of use, multi-use cases and no need for human intervention. It can dispense products like drinks, tickets, snacks, etc. by inserting currency coins. Vending machines are present in public and private areas like malls, markets, offices, etc. for various applications. In this project, we will build a portable drinking water vending machine using Arduino that can be used in any public place like tourist places to dispense drinking water or any other beverage using currency coins. This vending machine uses a single coin acceptor module to receive currency coins and uses TRIAC and optocoupler circuits to dispense water.


Components needed to build a Drinking Water Vending Machine:


Arduino UNO

Coin Acceptor Module

BT136 Thyristor

MOC3021 Optocoupler

Dot matrix perforated board

Connect the wires

Leading

230V AC water pump

Pipes and fittings

Drinking water vending machine working

pYYBAGLOhzaAC7JyAALybod5Gk8748.png

As shown in the block diagram above, the coin acceptor module acts as an input device and when it detects a valid coin inserted in it, it signals the Arduino. The Arduino receives the signal and issues a digital command to the Opto isolator which triggers the TRIAC to turn on/off the water pump for a specific duration. Similarly, an LED is connected to indicate the dispensing action.

Coin Acceptor Module Operation

poYBAGLOhzKAM8HQAAIW74ukFvU413.png

The coin acceptor module accepts currency coins that can be applied to various vending machines. There are multiple categories of coin acceptor modules including single coin acceptor, similar type coin acceptor, multi-coin acceptor, etc. Single coin acceptor is specifically designed to accept only a specific coin. Similar type coin acceptor is used to accept coins similar to the one placed in the coin acceptor. Multi-coin acceptor can accept different coins with one machine and output different signals to the microcontroller. In this project, single coin acceptor is used.

The coin accepting device has a built-in microcontroller which gets the data from the sensors inside the device and collects different coins. Using this data, the microcontroller knows whether that coin needs to be accepted or rejected. This device can be easily programmed using the buttons located on the top. The coin acceptor provides a pulse signal on the output pin for each inserted coin and by counting the pulses we know how many coins have been inserted. It also has three switches which we use to select the type of signal we want to get on the output. The first switch has three positions to select the pulse length. The second switch is used to set the signal to +5 V (NC) or 0 V (NO) as shown in the figure. Using the third switch, the accuracy of the device can be selected.

poYBAGLOhy6AbGoUAAE-GpA87Bk512.png

Coin Acceptor Module Training

To train a module for a specific coin, follow these steps:

First, press and hold the top button for 4-5 seconds until the red LED lights up, then release.

poYBAGLOhyqAcEn2AAHrvpPtzr8720.png

When the red LED is on, insert the coin for which we want to program. For example, if we want to program 2 rupee coin, then we will insert only 2 rupee coin while programming.

pYYBAGLOhyaARMmzAAI8ytn99Ig198.png

Insert the same coin into the device 30 times to train the coin memory. Once programming is complete, the LED will turn off and the device is ready for use.

pYYBAGLOhyKAaVJ8AAHFSmJyLls003.png

TRIAC Circuit Working

TRIAC is a three terminal AC switch which can be triggered by a low energy signal at its gate terminal. In SCR, it conducts in one direction only, but in case of TRIAC, power can be controlled in both directions. Here BT136 TRIAC is used for on/off purpose of AC pump switch.

poYBAGLOhx2AAmAVAAFO2NHpi48571.png

As shown in the figure above, the TRIAC is triggered by applying a small gate pulse signal to the TRIAC at a firing angle of 90 degrees. The time "t1" is the delay time that we have to give according to our application requirements. For example, in this case, since the firing angle is 90%, the average power output will be halved. If we want to turn on the device, we need to turn it on completely, that is, t1=0.

Optocoupler

Optocoupler is also known as Opto-isolator. It is used to maintain isolation between two circuits like DC and AC signals. Basically, it consists of an LED that emits infrared light and a photoelectric sensor that detects the infrared light. Here MOC3021 optocoupler is used to control the AC pump from our microcontroller signal which is a DC signal.

Water dispenser circuit diagram

pYYBAGLOhxmAQTMKAAIj6bPCxPg792.png

TRIAC and optocoupler connection circuit diagram

pYYBAGLOhxWAUijyAAGOqxhy0ps082.png

Programming an Arduino for a Vending Machine

Here, we will program the Arduino to detect the coin insertion and the type of coin. On successful detection, it will turn on the pump to dispense water. The complete code is given at the end of the document. Here, in the following lines, we will explain the important parts of the code.


First, define the pins used in the hardware as shown below. Digital pin 2 is used as the input interrupt pin, and digital pins 6 and 12 are used for TRIAC and LED respectively.

const int coin = 2;

const int TRIAC = 6;

const int LED = 12;

boolean Coin_insert = false;

integer count = 0;


Next, inside the setup function, an external interrupt pin will be configured to detect the insertion of a coin in the device. A function called attachInterrupt is used here which configures the digital pin 2 of the Arduino as an external interrupt and when it detects any interrupt on its pin, it will call the function called coinInterrupt.



void setup() {

SerialNumber.Start(9600);

attachInterrupt(digitalPinToInterrupt(COIN), coinInterrupt, RISING);

pinMode(TRIAC, OUTPUT);

pinMode(led, OUTPUT);

}


Inside Loop(), the coin insertion status is checked, and if a successful coin insertion is detected, the TRIAC is triggered for a specific duration to turn on the pump to dispense water, and then triggered off after completion.



void loop(){

if (coininserted) {

digitalWrite(led, HIGH);

delay(1000);

digitalWrite(TRIAC,HIGH);

delay(12000);

digitalWrite(TRIAC, LOW);

delay(2000);

COIN_INSERT = FALSE;

}

Other {

digitalWrite(led, LOW);

digitalWrite(TRIAC, LOW);

}

}


The function coinInterrupt is called when a hardware interrupt is detected, i.e. when the coin acceptor detects a valid coin.


void coinInterrupt() {

COIN_INSERTED = true;

}


Component assembly and testing


Now, after connecting the components as per the circuit diagram and programming the Arduino, let us build an enclosure similar to the vending machine as shown in the following image.

pYYBAGLOhw6AGF1wAAHisARKEdI186.png

After assembling all the units in one housing, the setup looks like this:

pYYBAGLOhwmAYbnmAAJQ_Dc-pCk559.png

The back view of the product is shown below.

poYBAGLOhwWAcrapAAVrPX753Ac717.png

To test the Arduino vending machine, turn on the power supply and place a glass inside the tap to collect the water. Now put a 2 rupee coin in the acceptor. Once it detects the coin, the green LED should glow and water should start dispensing. Once the glass is full, the LED and the pump should turn off.

That’s how you can build a drinking water vending machine with Arduino and coin acceptor module. If you have any questions or suggestions, you can put them in the comment section or use our forum .

Code

const int coin = 2;

const int TRIAC = 6;

const int LED = 12;

boolean Coin_insert = false;

integer count = 0;

void setup()

{

SerialNumber.Start(9600);

attachInterrupt(digitalPinToInterrupt(COIN), coinInterrupt, RISING);

pinMode(TRIAC, OUTPUT);

pinMode(led, OUTPUT);

}

void loop()

{

If (coin inserted)

{

digitalWrite(led, HIGH);

delay(1000);

digitalWrite(TRIAC,HIGH);

delay(12000);

digitalWrite(TRIAC, LOW);

delay(2000);

COIN_INSERT = FALSE;

}

Other

{

digitalWrite(led, LOW);

digitalWrite(TRIAC, LOW);

}

}

void coinInterrupt()

{

COIN_INSERTED = true;

}


Reference address:How to Build a Portable Drinking Water Vending Machine Using Arduino

Previous article:Hi3531DV200's excellent performance in video encoding and decoding
Next article:How to Build a Smart Wi-Fi Doorbell Using an ESP32 and a Camera

Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号