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
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
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.
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.
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.
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.
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.
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
TRIAC and optocoupler connection circuit diagram
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.
After assembling all the units in one housing, the setup looks like this:
The back view of the product is shown below.
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;
}
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
- Popular Resources
- Popular amplifiers
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- This is a camera development board, but where is the camera?
- Make announces its return
- The mysterious EMC, how did it come about?
- EEWORLD University - Zero-based circuit learning
- Appointment viewing double gift: How to ensure edge computing security? Learn about an important tool
- [Sipeed LicheeRV 86 Panel Review] 6-socket to achieve communication between different processes
- Usage diagram of various Arduino basic components
- [Transfer] C compiler version and predefined macros for system judgment
- AD21 interactive fast manual layout skills PCB reposition selected components in sequence reposition selected c...
- Diode frequency multiplier circuit, transistor frequency multiplier circuit