100% found this document useful (1 vote)
767 views63 pages

Vending Machine

This document describes a proposed machine learning based mask and sanitizer vending machine with plastic bottle disposal. A group of 6 students from Jimma University in Ethiopia developed this project under the guidance of their advisor Mr. Boaz B. The vending machine would use machine learning to detect Ethiopian currency and plastic bottles, allow contactless purchase of masks and sanitizer, and dispose of plastic bottles. It includes detailed sections on the background, objectives, methodology, requirements, design considerations, and simulation results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
767 views63 pages

Vending Machine

This document describes a proposed machine learning based mask and sanitizer vending machine with plastic bottle disposal. A group of 6 students from Jimma University in Ethiopia developed this project under the guidance of their advisor Mr. Boaz B. The vending machine would use machine learning to detect Ethiopian currency and plastic bottles, allow contactless purchase of masks and sanitizer, and dispose of plastic bottles. It includes detailed sections on the background, objectives, methodology, requirements, design considerations, and simulation results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 63

Machine learning based mask and sanitizer vending machine

JIMMA UNIVERSITY
JIMMA INSTITUTE OF TECHNOLOGY

Faculty of electrical and computer engineering

Computer engineering chair


Title: Machine learning based mask and sanitizer vending machine with plastic bottle waste
disposal system

Group members

1. Fikertemariam Mekonnen (RU1674/08)

2. Amanuel Nigatu ( RU2000/08)

3. Birhanu Guta ( RU1999/08)

4. Arefat Gebi (RU1067/08)

5. Mintesinot Tsegaye ( RU1863/08)

6. Israel Desta (RU1235/08)

Advisor: Mr. Boaz B.

Submission Date: Jan 28, 2021


Machine learning based mask and sanitizer vending machine

DECLARATION
We declare that this research entitled “Machine learning based mask and sanitizer vending
machine with plastic bottle waste disposal system” Is our own original work and has not been
submitted as a requirement for the award of any degree in our university or elsewhere.

Group members id no signature

1. Fikertemariam Mekonnen RU1674/08

2. Amanuel Nigatu RU2000/08

3. Birhanu Guta RU1999/08

4. Arefat Gebi RU1067/08

5. Mintesinot Tsegaye RU1863/08

6. Israel Desta RU1235/08

As research advisor, I hereby certify that I have read and evaluated this project paper prepared
under my guidance, entitled Machine learning based mask and sanitizer vending machine with
plastic bottle waste disposal system.

Advisor: Mr. BOAZ B.

Signature Date
Machine learning based mask and sanitizer vending machine

ACKNOWLEDGMENT

First and foremost, we would like to express our deepest gratitude for Jimma University Institute
of technology: faculty of electrical and computer engineering for preparing this interesting and
so much valuable project design which helped us improve our knowledge and have confidence as
well as for providing us the necessary materials to come up with a solution and meet the
requirements made. Next, we would like to express our great thanks to our advisor Mr. Boaz B.
who spent his time in giving suggestions, comments and his knowledge to develop our duty on
the design and implementation of this project. Last but not least the guidance and support
received from all the teachers and members who contributed to this project, was vital for the
success of this project and we are grateful for their support.
Machine learning based mask and sanitizer vending machine

Table of Contents Page No


Acronyms ....................................................................................................................................................... I

ABSTRACT................................................................................................................................................. II

CHAPTER ONE ........................................................................................................................................... 3

INTRODUCTION ........................................................................................................................................ 3

1.1 BACKGROUND ................................................................................................................................ 3


1.2 STATEMENT OF THE PROBLEM .................................................................................................. 4
Solution proposed ..................................................................................................................................... 5
1.3 SCOPE ................................................................................................................................................ 5
1.4 OBJECTIVES ..................................................................................................................................... 6
1.4.1 General Objectives ....................................................................................................................... 6
1.4.2 Specific Objectives ...................................................................................................................... 6
CHAPTER TWO .......................................................................................................................................... 7

LITERATURE REVIEW ............................................................................................................................. 7

CHAPTER THREE .................................................................................................................................... 12

METHODOLOGY ..................................................................................................................................... 12

3.1 Architecture of the system ................................................................................................................ 12


3.1.1 Software methodology ............................................................................................................... 12
3.1.2 Hardware methodology .............................................................................................................. 14
3.2 Instrumentation and Data collection ................................................................................................. 14
3.2.1 Observation ................................................................................................................................ 14
3.2.2 Data Collection .......................................................................................................................... 15
3.2.2 Documentary Analysis ............................................................................................................... 15
3.2.3 Brainstorming ............................................................................................................................ 15
3.3 work plan .......................................................................................................................................... 16
3.4 System block diagram ....................................................................................................................... 17
3.5 Material Specifications ..................................................................................................................... 18
3.5.1 Software Requirements .............................................................................................................. 18
3.5.2 Hardware Requirements............................................................................................................. 19
3.6 Design consideration of the system .................................................................................................. 24
3.6.1 Flow Chart ................................................................................................................................. 24
Machine learning based mask and sanitizer vending machine

3.6.2 Use Case Diagram...................................................................................................................... 25


3.6.3 Sequence Diagram ..................................................................................................................... 26
3.6.4 Design of birr currency and plastic bottle detection mechanism ............................................... 27
3.6.5 Design of GUI Representation ................................................................................................... 28
3.6.6 Design of 3D model of the vending machine............................................................................. 28
CHAPTER FOUR....................................................................................................................................... 29

Results and Discussions .............................................................................................................................. 29

4.1 Requirements of the system .............................................................................................................. 29


4.1.1 Functional Requirements ........................................................................................................... 29
4.1.2 Hardware Requirements............................................................................................................. 29
3D Model Explained ........................................................................................................................... 31
4.1.3 Software Requirements .............................................................................................................. 33
GUI Representation Explained ........................................................................................................... 33
4.2 SIMULATION RESULT.................................................................................................................. 38
Test Performed ............................................................................................................................................ 41

CHAPTER FIVE ........................................................................................................................................ 44

LIMITATIONS AND FUTURE WORKS ................................................................................................. 44

LIMITATIONS ........................................................................................................................................... 44

FUTURE WORKS...................................................................................................................................... 44

CHAPTER SIX ........................................................................................................................................... 45

CONCLUSION AND RECOMMENDATION .......................................................................................... 45

CONCLUSION ........................................................................................................................................... 45

RECOMMENDATION .............................................................................................................................. 46

REFERENCES ........................................................................................................................................... 47

APPENDIX ................................................................................................................................................. 48
Machine learning based mask and sanitizer vending machine

List of Figures Page No


FIGURE: 2. 1 Drinks Vending Machine ...................................................................................................... 9
FIGURE: 3. 1 RAD methodology............................................................................................................... 12
FIGURE: 3. 2 Data collected ...................................................................................................................... 15
FIGURE: 3. 3 System Block Diagram ........................................................................................................ 17
FIGURE: 3. 4 Raspberry pi ........................................................................................................................ 20
FIGURE: 3. 5 Relay.................................................................................................................................... 21
FIGURE: 3. 6 Servo motor ......................................................................................................................... 22
FIGURE: 3. 7 Infrared Sensor .................................................................................................................... 22
FIGURE: 3. 8 LCD Display........................................................................................................................ 23
FIGURE: 3. 9 Flowchart ............................................................................................................................. 24
FIGURE: 3. 10 Use case Diagram .............................................................................................................. 25
FIGURE: 3. 11 Sequence Diagram ............................................................................................................. 26
FIGURE: 3. 12 Samples of Data Collected ................................................................................................ 27
FIGURE: 4. 1 User Interaction ................................................................................................................... 30
FIGURE: 4. 2 3D Model Frontal Picture .................................................................................................... 31
FIGURE: 4. 3 Side views of the 3D model................................................................................................. 32
FIGURE: 4. 4 GUI Representations ........................................................................................................... 33
FIGURE: 4. 5 GUI of the system with 5 birr .............................................................................................. 34
FIGURE: 4. 6 GUI of the system with 10 birr ............................................................................................ 35
FIGURE: 4. 7 GUI of the system with plastics........................................................................................... 36
FIGURE: 4. 8 GUI showing invalid input .................................................................................................. 37
FIGURE: 4. 9 Simulation Result ................................................................................................................ 38
FIGURE: 4. 10 simulation showing mask dispensing ................................................................................ 39
FIGURE: 4. 11 simulation showing return of input when invalid .............................................................. 40
FIGURE4. 12 Performance of the system .................................................................................................. 43
Machine learning based mask and sanitizer vending machine

List of tables Page No


TABLE: 3. 1 Work Plan ............................................................................................................................. 16
TABLE: 3. 2 Hardware Requirements ........................................................................................................ 19

TABLE: 4. 1 Test Performed ...................................................................................................................... 41


TABLE: 4. 2 Functionality Testing Phase 1 ............................................................................................... 41
TABLE: 4. 3 Functionality Testing Phase 2................................................................................................... 41
Machine learning based mask and sanitizer vending machine

Acronyms
3D 3dimension

AI Artificial Intelligence

DC Direct Current

MOSFET Metal oxide field effect transistor

GUI Graphical User Interface

HD High Dimension

IR Infrared

KG Kilograms

LCD Liquid Crystal Display

LED Light Emitting Diode

RAD Rapid Application Development

RFID Radio Frequency Identification

SDLC System Development Life Cycle

U.S. United States

I
Machine learning based mask and sanitizer vending machine

ABSTRACT
Sanitizers and masks have become the most commercial products of the year considering the
pandemic issue that has happened all around the world. Due to the rapidly rising population the
stress on the multiple resources of masks and sanitizers has been remarkable. The problems
encountered caused a change in people’s life style and thus needing a better modernized solution.
Vending machine is a system that helps to get/ acquire the items needed.

To avoid these problems this project titled “Machine learning based mask and sanitizer vending
machine with plastic bottle waste disposal system” is aimed at proposing a machine which can
vend the mentioned items to the customer with the appropriate methods of developing the
functionalities needed. This project is based on machine learning technology which is one way of
developing a system with image processing for the identification of birr currency note for the
country. This identification mechanism is done through an image processing technology which is
embedded to a raspberry simulation. The raspberry simulation has let a camera to interact with it
for the sake of identifying the input through the machine which after the camera takes in shot of
the input the camera, the raspberry validates the input. The fact that this project is based on
image processing minimizes the unnecessary costs of using different sensors for the validation/
assurance of the correct birr currency into the machine since image processing uses nothing but a
code done on a collected data. After validation process is completed via image processing the
next step which is done on proteus simulation shown on this project layout will be completed
based on the customer’s preferences.

The machine is helpful since it is convenient, efficient and user friendly to use. It is cost effective
to use compared to other vending machines as the tools used are reduced by way of machine
learning in this project thus providing a better vending method than others. Therefore this project
aims at developing a system whereby people’s way of life making it easy and interesting.

II
Machine learning based mask and sanitizer vending machine

CHAPTER ONE

INTRODUCTION

1.1 BACKGROUND
Sanitizers and masks have become the most commercial products of the year considering the
pandemic issue that has happened all around the world. Due to the rapidly rising population the
stress on the multiple resources of masks and sanitizers has been remarkable. The problems
encountered caused a change in people’s life style and thus needing a better modernized solution.

With the improvement in the technology there are many advanced machineries useful for
mankind. One of them is a coin operated telephone. This machinery has been very useful to the
community and has been giving service in our country for quite some time now. With the same
way and technology, the telephone machine operates, in this project the service is changed into
providing a mask and sanitizer for the individual requesting the items based on their preferences.
It has been designed to be used in public places where the scarcity might happen.

The demand for machineries like a vending machine has increased due to the change in the
lifestyle of people however there is a seldom usage in them. The machine has numerous input
and output to provide service to the customer. It accepts coins as well as plastics for recycling
purpose as an input to provide service to the customer. So this project not only provides an easy
access to the items but also avoids environmental pollution while doing so.

Looking at the specifications required for the vending machine and for the simplicity of our
application and the system, machine learning was used. Since the money currency that is used to
request for the items that are needed by the consumers need to be identified as a real currency to
give a service, Image processing is through machine learning is used to identify the real note.
After identifying, through a raspberry pi simulation it’s to be shown that the machine dispenses
the items that are required with a fixed annotation of Ethiopian currency notes (5 birr and 10
birr).

3
Machine learning based mask and sanitizer vending machine

In addition to the input of money, this project also explains how a plastic input system works /
functions the vending machine. This is done by measuring the weight of the recyclable plastics
which are inserted into the machine by the customer to get the service that is desired. For that
reason, a weight sensor is used to measure the weight of the plastics inserted into the machine to
identify whether the person have given sufficient amount of plastics. And once the person has
inserted enough amounts of plastics/ based on the programmed amount in KG, the machine will
easily make the items available to be dispensed.

1.2 STATEMENT OF THE PROBLEM


In our community there is no smart way of introducing the items we need with an easy access.
Although there is a demand for it, being technologically in advanced there is seldom usage of
vending machines for the items we need. Currently, facial masks and sanitizers are a big
marketing issue in our country. The need to distribute these items in every place at any time is
also a big issue. This project aims at improving this state of condition and makes the items
available anywhere.

In the recent time, the need for facial masks and sanitizers has increased tremendously due to the
pandemic that has caused millions to get infected and to die all around the world. Likewise, the
pandemic has caused social, political as well as economic disruption in our country. Among one
of the many mischiefs that has happened is the scarcity in supply of well-prepared masks and
sanitizers to the large community.

Currently, the majority people purchase these items which help prevent the pandemic through a
very harmful way. These items are being sold to the majority through hand by hand on the street
in the absence of sanitized area and since the facial masks and sanitizers are to be kept out of
contagion due to the feared viruses and bacteria which are very contagious. Because of this the
current marketing system is very endangering for the community with less income.

There is another concern for the community in regarding to plastics which is a disastrous
situation nowadays. Plastics are being thrown everywhere. It’s a well-known fact that the
disposal of plastics into the environment is very hazardous and it’s causing diverse associated
problems. Environmental pollution is a major environmental burden if not handled carefully. The
solution to this big concern is recycling the existent plastics and reducing the manufacturing

4
Machine learning based mask and sanitizer vending machine

capacity. When coming to the concept of recycling there is a little awareness of the
hazardousness of the plastics to the environment in our country and due to this majority of the
people has an unpleasant way of disposal.

In our country wasted plastics are one of main problem, by making the environment polluted and
unattractive. Especially, garbage’s that are made up of plastics are the main contributors of this
pollution. Plastics are harmful for environment because they take lots of years to degrade. They
take many years to decompose. If we collect those plastics and keep it somewhere, it cannot be a
solution. It leads to other pollution. Thus, the solution of this problem is recycling and rebuilding
those plastics to a useful material.

Solution proposed
This project proposes a solution for these problems by proposing a system where by a vending
machine works with 2 input systems (coin and plastics). It takes plastics as an input and delivers
the mask/sanitizer based on the consumer preference and the amount of the plastics that person
inserted into the machine. It is a machine which will provide service by itself and the customer
could easily purchase him/herself free from any contagion. In addition to that, it will accept
plastics as an input creating a motivation for the community to dispose plastics in the appropriate
manner. Thus, protecting the environment from new hazards every day.

1.3 SCOPE
The aim of this project is to design, develop and implement a vending machine that vends masks
and sanitizers. This machine is capable of scanning a 5 birr and 10 birr Ethiopian currency notes.
This project has three main parts. The first one is a part that gives a choosing option to the
customer while displaying the amount the customer needs to dispend into the machine to get the
service. The second is a part which accepts and validates birr/plastics, which is designed by
software that makes sure the note qualifies for the real currency. Developing software that is
used for the image processing is the third part of the project. This designing software will be able
to process the image through the camera that is going to be connected through the raspberry pi
port. Finally, after the data is validated the machine will dispense the desired product.

5
Machine learning based mask and sanitizer vending machine

1.4 OBJECTIVES

1.4.1 General Objectives


The main objective of this project is to design, develop, implement and test vending
machine for masks and sanitizers.

1.4.2 Specific Objectives


o To gather information regarding vending machines and image processing.
o To list the requirements of the system.
o Design the features of the Coin identification system in terms of image
processing.
o To give solution to the current situation of environmental pollution in terms of
recycling plastics by using them as an input.
o Develop the vending machine system with Raspberrypi based kit interfacing with
machine learning.
o To test the acceptability of the developed system.
1.3 Significance of The Project
Nowadays there is much advancement in technology which made our day to day activities more
efficient and comfortable. Among so many interesting innovations vending machine technology
have been to serve the community with a coin based telephone service. The earlier service was
very helpful to the community as it lets anyone who has a coin to make a telephone call for 24
hours. The best thing about all vending machine is that they are user friendly to use. The vending
machine which dispenses masks and sanitizers in this project is also user friendly machine which
gives services on a 24 hours basis throughout the year without the involvement of stuff or human
assistance.

One of the core ideas in making the dispensable items masks and sanitizers in this project is due
to the incredibly high demand of usage in them at anytime and anyplace. And in addition to that,
these items need to be handled very cautiously to eliminate the contagion of any bacteria and
viruses. Due to that it requires a machine which is clean enough and free from any contagions to
deliver the items instead of when handling the transaction between people.

6
Machine learning based mask and sanitizer vending machine

These vending machines meet the requirement of the people since they do not need much
attention and time to work. Minimum time is required to keep them serviced and stocked with
product. When we come to the marketing business strategy of it, one of the greatest things is that
vending machines don’t have advertisement and marketing costs and no overheads cost as it
eliminates the need for the employees who sell products. And it can also work in a small working
space.

7
Machine learning based mask and sanitizer vending machine

CHAPTER TWO

LITERATURE REVIEW
History of Vending Machine

Although the practice of machines like a vending machine in our country is not well practiced,
there has been a practice of it all around the world with a different motive or purpose for using.
Even though it may be thought that vending machines are modern convenience they actually go
way back to ancient times. To take a note of the first vending machine that was invented was that
of the ancient Greek mathematician and engineer hero of Alexandra. It started with an invention
that took coins and dispenses holy water. Once the coin went into the machine, it would roll and
drop into a pan attached to a lever. The weight of that coin would release a flow of water. The
next form of vending machines came in England sixteen centuries later. The devices were made
of brass and sat in taverns to sell tobacco. Then, an English bookseller by the name of Richard
carlie sold banned books through a vending machine in 1882. The machines like we know them
today were created in the 1880s and were first introduced in the U.S. as items that sold postcards
and notepaper, among other things, in train stations and post offices [1].

Coin-operated machines

During the 1880’s, the first coin operated vending machines were introduced in London,
England. The machines were commonly found at railway stations and post offices because they
were convenient for purchasing envelops, postcards and notepaper. In 1887, the first vending
machine servicer, the sweetmeat automatic delivery co., was founded. And that’s how the
vending machine got introduced to the U.S. and installed on the elevated subway platforms in
New York and sold a gum. Following the coin operated gum dispense machine soon there was a
coin- operated restaurants in Pennsylvania which was opened in 1902 and lasted 1962.

The country most well-known for its usage of a vending machine is Japan. Japan has a reputation
for having some of the most innovative uses of automated vending, providing machines that
offer fresh fruits and vegetables, sake, hot foods, batteries, flowers and clothing. Japan has the
highest per capital rate of vending machines in the world. [2]

8
Machine learning based mask and sanitizer vending machine

Drinks vending machines

The most popular dispensed item among all the items is considered to be drink and snacks. The
vending machines that dispense soda into cups came around in the early 1900s and in 1937, they
began dispensing bottles drinks. Coca-Cola was the first and Pepsi soon followed suit. Once the
technology was perfected, vending machine with snacks came about as well. In the mid-2000s,
companies began installing credit cards onto vending machines so customers wouldn’t have to
have the right change. They could also sell higher priced items like laundry items, over the
counter medications and other products [2].

FIGURE: 2. 1 Drinks Vending Machine

Snacks vending machine

Barsha Samantray (2019). Implementation of an automatic chocolate vending machine based on RFID
and arduino UNO. Electrical Engineering. This paper approaches an automatic chocolate vending
machine which uses a combination of arduino uno and RFID technology. The machine is useful on places
where people gather a lot and saves time. It provides 3 different types of chocolates and also involves 3
types of RFID cards. This work is based on coin that only accepts some particular coins as programmed
in microcontroller. Here rather than inserting the coin to buy the product, one has to scan the RFID card

9
Machine learning based mask and sanitizer vending machine

to buy the product. After reading the card by the reader some options of products come on the screen in
front of the user. Then user has to select one of those options, later some amount from the RFID card will
be deducted corresponding to the chosen product and machine provides the selected product at its output
[3].

Vishal, T. Sushmita, W. Nishant, J. (2017). medicine dispensing machine using raspberry pi and Arduino
controller. Electronics and communication engineering. They proposed a project whereby it presents a
machine designed to provide health care at areas where having a medical store may not be feasible or
possible. It allows the user to select a medicine, pay the required amount after it verifies the amount
received and dispense the medicine. It uses an image processing unit controlled by raspberry pi to
authenticate the amount. While the payment module and medicine dispensing modules are controlled by
the Arduino which is connected to the raspberry pi serially (USB cable) [4].

Shweta Dour, Rishikesh Shukla, Dishita Makwana, et el. (2017). Vending machine using 8051 Microcontroller.
Electrical and Electronics Department. This paper presents a vending machine which operates with coin meaning
that it is coin based. While these machines can be implemented using different methods this project paper used a
microcontroller 8051. Like the mentioned vending machines these machines also aim at making it easy for small
purchases [5].

D V Raagu, Gayaz Mohamed, Md Mohiyuddin Sharif, et el. (2016-2017). Design and fabrication of coin
operated portable water vending machine. Mechanical Engineering. This project is proposed to reduce the
stress on the multiple water resources due to the rapidly rising population and the increased need for fresh
water. It delivers the purified water to the public by using the sensors and microcontrollers based on the
mechatronics principles and operate with different coin [6].

K.R.Nimisha, K.Indumathi, R.Divyamani. et el. (2017). Smart Newspaper Vending Machine. Department
of ECE. This project titled “smart newspaper vending machine “is proposed to deliver the newspaper to
the public by using the better user interface and microcontrollers based on the mechatronics principles.
Which is cheap to deliver to college students It is designed to deliver the newspaper by scanning the
respective RFID tag which was given by the agent [7].

10
Machine learning based mask and sanitizer vending machine

Summary of the literature:

This project paper takes the same approaches with some features added to it and the scope being defined
on the current issue. The fact that it vends a mask/sanitizer is very suitable for the large community. In
order to minimize the cost and the communities’ need of using a less costly system image processing is
used to identify the birr currency rather than additional sensors. The raspberrypi simulation is done by
having an image processing as to identify the birr currency. In addition to this main operating system, this
project also proposes an idea of a vending machine which operates by another input which is plastic by
measuring the weigh and providing service the same way as the coin does. This will be beneficial for the
environment as it helps prevent the improper damping of plastics and will help people have know-how
about the hazardousness of plastics on the environment and the good side of recycling plastics.

11
Machine learning based mask and sanitizer vending machine

CHAPTER THREE

METHODOLOGY

3.1 Architecture of the system

3.1.1 Software methodology


There are many different systems development methodologies, and each one is unique based on
the order and focus it places on each SDLC phase. So we selected RAD with Agile Methodology
because RAD methodology is a way to create software quickly and efficiently, without having to
resort to development models like the other models, which are inflexible, making it difficult to
change functions and features once we have built the software. RAD method is designed to be
flexible and to accept new inputs, like features and functions at every step of the development
and since our project has added features to it and at the end of every development cycle steps, we
use the requirements to verify that the finished application/development cycle step actually does
what it’s supposed to do or not. And then by using RAD we can change or add the features that
we wish to modify. Not only does the RAD methodology give us a better feature manipulating
activities but also, it can be useful in code reusability, shorter development time saving us time,
frequent customer feedback or user involvement, more accurate requirements and greater chance
of success.

FIGURE: 3. 1 RAD methodology

12
Machine learning based mask and sanitizer vending machine

Based on the steps shown above by the block diagram, we can classify the RAD method approach into 4
different steps.

Requirements planning: -

On this step of development, we agreed on the system goal and requirement such that the requirement
plan we did, does not restrict later development unnecessarily. And so, we have planned to do a vending
machine where anyone can easily request the item they need (mask or sanitizer) and get it. The machine is
supposed to vend the items after the verification process of the input money is assured. In addition to the
money this machine also goes through a verification process for plastic bottles. The verification process is
done by image processing. These requirements are essential in this project as these are the main
requirements that we need to fulfill in assembling a vending machine so as to modify the current existing
system in a better way.

User design: -

Next to planning the requirements, we have planned a better efficient and well organized way of meeting/
fulfilling those requirements by a method of brainstorming. Since we have worked on the project by
group the best way to design/develop the system is by using the ideas that emerge from different one of
us, analyze those ideas and coming into a specific way of path to developing the system.

Construction: -

After designing the system, we have received a comment/ suggestion to improve the work we have done
on the project. We first planned out the system material requirements based on the functional requirement
that needs to be done including the essential concept of reducing the overall cost of the system. Based on
that we then started coordinating the material specifications in an efficient and organized manner as
shown by the block diagram. After organizing the block diagram and briefly explaining the working
principles of each individual materials and the interacting principles of those materials with other
materials in the system, we then assembled it on the proteus software, simulated it and saw the output.
That’s why it has evolved into a better performing project than what it was first designed for.

Cut over: -

This is the final stage where we deliver the finished product/project by incremental deployment either to
the examiner or the department as this is a project on high level education and currently can’t be delivered
to the customers. On this model, the user design and construction phases overlap with the users constantly
providing adjustments to the developers in a sort of continuous feedback loop. The project iterates the

13
Machine learning based mask and sanitizer vending machine

user design and construction phases as needed. When the application has met all the requirements, it is
delivered to the users.

3.1.2 Hardware methodology


To design and implement the system hardware, we considered a compromising method in the way
hardware and software components of a system work together to exhibit a specified behavior, given a set
of performance goals and an implementation technology. And so by considering the software in
implementing the hardware, we concentrate on creating a special purpose system composed of a few
application specific integrated circuits cooperating with software procedures.

Such embedded systems are characterized by a single, well defined purpose at a definite point in time and
by generally long life time. This development stage cannot be carried out by trial and error method as the
damage is high leading to a higher cost. So before the overall deployment, our method of performing on
the hardware materials will be such that it will be carried out at completely as possible during the early
design phase step by step.

3.2 Instrumentation and Data collection


For the successful completion of this project the instrumentation we used is observation, documentary
analysis and brainstorming.

3.2.1 Observation
By observing we meant to say what we have saw because accuracy of observation is the equivalent of
accuracy of thinking. Particularly, we have tried to see the problems that are encountered and are in
involvement of every day to day lives of the community which helped 6 us to come up with the idea of
using vending machine and introducing to the community a smart way of life. In addition to observing the
problems we have also observed how easily the people are interacting to the materials we are going to
interface them to and also the availability range of the materials.

14
Machine learning based mask and sanitizer vending machine

3.2.2 Data Collection


Different kinds of materials have been collected for the successful completion of the project.

FIGURE: 3. 2 Data collected

3.2.2 Documentary Analysis


The documents have been reviewed to access an appraisal theme. Almost all the documents are some sort
of public records such as yearly reports, understudy handbooks, statements of purpose and vital
arrangements which are analyzed to accumulate requirements amid for a project as well as to extract
relevant data regarding the requirements done.

3.2.3 Brainstorming
Brainstorming is the best approach when it comes to finding out a way to do and on bringing the system
requirements to success to come up with ideas on data collection as well as instrumentation.
Brainstorming is group creativity techniques by which efforts are made to find a conclusion for a specific
problem by gathering a list of unrestrained ideas contribute by the team members. This was the most
effective method when it comes to our project since we were able to think more freely and suggest new

15
Machine learning based mask and sanitizer vending machine

ideas and after that the suggested ideas were noted down and after the brain storming session ended those
ideas were evaluated.

3.3 work plan


It is shown here the timeline of the project by using Gantt chart which is a kind of bar chart used to show
a schedule for a collection of related tasks. This project is done within 8 weeks’ duration.

TABLE: 3. 1 Work Plan

Weeks/activities 1 2 3 4 5 6 7 8
Requirement
planning
User design
Construction
cutover

16
Machine learning based mask and sanitizer vending machine

3.4 System block diagram

FIGURE: 3. 3 System Block Diagram

General block diagram of mask/sanitizer vending machine using raspberry pi has been shown
above. It consists of three sections, these are: - input, the controller and output sections. First the
controller section remains at waiting state for receiving a signal from input section which
includes infrared sensor and the camera. . The controller section validates the input through the
camera and takes decision and activates the output section which includes LCD display, DC
Motors and Bulbs. The switch in this block diagram represents 5 / 10 birr. It is switched on/ off
to show valid / invalid birr in the simulation. Once the switch is on one of the motors starts
which indicate it will vend the item.

17
Machine learning based mask and sanitizer vending machine

3.5 Material Specifications


In designing and implementing this project paper, we have used both software and hardware
approaches embedded together to fulfill our basic requirements as explained on the
methodology. So based on our requirements and the data we collected, we have done the
specification of the materials we need as well as the cost of the overall system.

3.5.1 Software Requirements


o Proteus 8.9:- is a Virtual System Modeling (VSM) that combines circuit simulation,
animated components and microprocessor models to co-simulate the complete
microcontroller based designs. We use this software to design hardware circuit
simulation.
o Google colabs: - is cloud service that also support python. Students and professional
programmers use colab to learn how to use deep learning applications via tensor flow,
keras, opencv, and pyTorch. We use this software to train our data set and to get our
final machine learning model.
o Qt designer: - Is a free and open-source widget toolkit for creating graphical user
interfaces as well as cross-platforms applications that run on various software and
hardware platforms such as Linux, Windows, macOS, Android or embedded systems
with little or no change in the underlying code-base while still being a native application
with native capabilities and speed. We use this software to develop desktop application
to show how image is being captured and processed to move servo motor and deliver the
product. [8]
o TensorFlow2: is a free and open-source library for machine learning. It can be used
across a range of tasks but has a particular focus on training and inference of deep neural
networks.
o Custom Vision: - The Custom Vision service uses a machine learning algorithm to
analyze images. the developer, submit groups of images that feature and lack the
characteristics in question. You label the images yourself at the time of submission.
Then, the algorithm trains to this data and calculates its own accuracy by testing itself on
those same images. Once the algorithm is trained, you can test, retrain, and eventually
use it in your image recognition app to classify new images. [9]

18
Machine learning based mask and sanitizer vending machine

o Blender: - is a free and open-source 3D computer graphics software toolset used for
creating animated films, visual effects, arts, 3D printed models, motion graphics,
interactive 3D applications, virtual reality and computer games. We used this software
for design a 3D model for our vending machine. [9]

3.5.2 Hardware Requirements


TABLE: 3. 2 Hardware Requirements

MATERIALS SPECIFICATIONS AMOUNT


Raspberrypi ANIMATED 1
Relay 12V 7
Button ANIMATED 3
Switch ANIMATED 7
Transistor NPN 7
LED ANIMATED 3
Servo Motor 12V 5
LCD16*2 LM016L 1
Obstacle Infrared ANIMATED 2
Diode 1n4007 7
DMOS FET 2N6660 8

19
Machine learning based mask and sanitizer vending machine

Raspberry pi:

FIGURE: 3. 4 Raspberry pi

Raspberry pi is a series of small single-board computers which is a low cost, credit-card sized
computer that plugs into a computer monitor or TV and uses a standard keyboard and mouse. It
has a dedicated camera input port that allows users to record HD video and high-resolution
photos. It enables to use python and specific libraries written for the pi, making it easy to take
photos/videos, analyze them in real-time or save them for later processing. In this project this
credit card sized material was used in such a way as to identify the birr currency after the user
has entered the money in.

20
Machine learning based mask and sanitizer vending machine

Relay:

FIGURE: 3. 5 Relay

A relay is an electromagnetic switch that is used to turn on and turn off a circuit by a low power signal, or
where several circuits must be controlled by one signal. It is used to convert small electrical stimuli into
larger currents. These conversions occur when electrical inputs activate electromagnets to either form or
break existing current.

In this project, the relays are used to turn on the motor that is supposed to vend an item from the strage by
making a whirl turn. The program writes a high value top in 3, which activates the octocoupler which in
turn switches on the transistor. When the transistor turn on, the current flows through the relay coil
causing the relay to close, which connects 12v across the motor, causing it to spin.

21
Machine learning based mask and sanitizer vending machine

Servo Motor:

FIGURE: 3. 6 Servo motor

Servo motor is a self-contained electrical device that rotates parts of a machine with high efficiency and
with great precision. The output shaft of this motor can be moved to a particular angle, position and
velocity that a regular motor does not have. This motor is used in this project as it is the key element in
vending or moving the items to place.

OBSTACLE INFRARED SENSOR:

FIGURE: 3. 7 Infrared Sensor

22
Machine learning based mask and sanitizer vending machine

It is built in IR transmitter and receiver that sends out IR energy and looks to detect presence of any
obstacles in front of the sensor module. The module has on board potentiometer that lets user adjust
detection range. We use this sensor in order to detect inputs and initialize the camera for machine learning
process.

LCD (16*2) DISPLAY:

FIGURE: 3. 8 LCD Display

Liquid Crystal Display (LCD) is a flat panel or other electronically modulated optical devise that uses the
light-modulating properties of liquid crystals. Liquid crystals do not emit light directly, instead using
a backlight or reflector to produce images in color or monochrome. A 16x2 LCD display is very basic
module which is commonly used in various devices and circuits. A 16x2 LCD means it can display 16
characters per line and there are 2 such lines. This LCD is required in this project in order to display the
necessary information and guidance for the user on the screen.

23
Machine learning based mask and sanitizer vending machine

3.6 Design consideration of the system


3.6.1 Flow Chart: The following flow chart shows the sequence of the vending machine. As it can be
seen from the diagram after the user inserts money which is either 5 or 10 birr or plastics into the
machine, the machine will validate the money and let the user have the item they requested.

FIGURE: 3. 9 Flowchart

24
Machine learning based mask and sanitizer vending machine

3.6.2 Use Case Diagram

FIGURE: 3. 10 Use case Diagram

The use case is a description of how users will perform tasks and outlines a system’s behavior as it
responds to a request. And it is represented as a sequence of simple steps beginning with a user’s goal and
ending when that goal is reached. As it can be seen from the diagrams, the customer/ user interacts to the
system and gets services which are labeled in a circle.

25
Machine learning based mask and sanitizer vending machine

3.6.3 Sequence Diagram

FIGURE: 3. 11 Sequence Diagram

The Sequence Diagram is interaction diagram that detail how the operation of a vending machine
mechanism is carried out and shows runtime interactions between the parts that make up the system

26
Machine learning based mask and sanitizer vending machine

3.6.4 Design of birr currency and plastic bottle detection mechanism


The steps used in designing the image processing for the detection of birr currency

o Collection of data sets: more than 1200 pictures of data were collected. The data include 5 birr,
10 birr and different kinds of plastic bottles. The data’s were different collected from different
angles, orientations and formation.

FIGURE: 3. 12 Samples of Data Collected

27
Machine learning based mask and sanitizer vending machine

o Splitting: The next process was splitting of the collected pictures to train and test classes. Since it
is a good practice to use validation split when developing the model, 20% of the pictures was
used for testing and the rest 80% was used to train. This percentage was used to make the
accuracy high.
o Choosing the appropriate tool: Following the split process we choose the appropriate tool for
labeling images and training the model which is custom vision AI software was used for both
labeling and training the plastic bottles and money.
o Training our model
o Testing the accuracy of our model and training the results. During this stage over fitting could
happen. Over fitting is when the difference in accuracy between training and validation accuracy
is noticeable meaning that the model will have a difficult time generalizing on a new dataset. To
solve this problem, we use data augmentation and add Dropout to our model. Data augmentation
takes the approach of generating additional training data from your existing examples by
augmenting those using random transformations that yield believable looking images and expose
the model to more aspects of the data and generalize better.
o Predicting on new data
o Finally, we were able to detect an image that was not included in the training dataset.

3.6.5 Design of GUI Representation

In order for the customer to interact with the system, we develop a graphical interface that is displayed on
the vending screen which interacts with the machine learning model.

3.6.6 Design of 3D model of the vending machine

The 3d modeling for the vending machine is developed to help for a better designing and for the end users
to visualize space requirements and improve accuracy. We used blender (3d model tool) to show how the
overall system would look like when it is assembled. The machine is required to have buttons for
choosing the items, birr and plastic entering dashboard, has a plastic collector and item placing slots,
spirals which are connected to the motor and used for rotating and dispensing and motors running for the
purpose of vending or dispensing. This overall requirement of the machine is to be designed by blender
and show the 3d model.

28
Machine learning based mask and sanitizer vending machine

CHAPTER FOUR

Results and Discussions

4.1 Requirements of the system


Requirements are the features that the system must provide. By the process of gathering the
requirements and refining them, we came to a generalization of acquiring what is aimed to
achieve. We classified the process of analyzing the findings by the process of three ways of
obtaining the requirements.

4.1.1 Functional Requirements


Functional requirements are detailed statements of the project’s desired capabilities. These
requirements are the types of requirements that consist of the operations and the activities that a
system must be able to perform.
 The machine accepts valid birr currency notes
 It injects invalid currency notes
 It allows users to choose the item they want
 It allows users to insert either money or plastics for the item they want
 It gives brief/ guidance to the users through the LCD
 It vends the items to the users

4.1.2 Hardware Requirements


The hardware requirement is simply the way we tried to achieve the functional requirements by
using the less costy, functional, effective, more time efficient materials as well as those materials
which are easy to assemble and which are available in the market easily. The details of these
materials and their function is explained on the block diagram description of the system on
chapter 3 and it can also be explained in a flow chart and system diagram by two different ways
as follows.

29
Machine learning based mask and sanitizer vending machine

FIGURE: 4. 1 User Interaction

The above figure shows the basic hardware interacting system. The user interacts with main
controlling unit by inserting money through the vending machine. And by interacting, vending of
items is possible.

30
Machine learning based mask and sanitizer vending machine

3D Model Explained
To visualize the system, blender (3d model tool) is used to show how the overall system would
look like when it is assembled.

FIGURE: 4. 2 3D Model Frontal Picture

This is the frontal view of the 3D model of vending machine as designed by the blender tool. It
shows how the items are arranged within the spiral spring like structure. It shows clearly what
item belongs to what button so that it can be user friendly and easy to use. It can also be seen
where a birr or plastic input space is and users can be assisted based on the display on the screen.

31
Machine learning based mask and sanitizer vending machine

Side views of the machine where


plastics that are inserted into the
machine are stored. Detail inside
pictures of the items being stacked is
also shown in the figure.

FIGURE: 4. 3 Side views of the 3D model

32
Machine learning based mask and sanitizer vending machine

4.1.3 Software Requirements


Based on the RAD method of system development, we have designed the system code which is
aimed at being embedded with hardware materials in the hopes of achieving the functional
requirements. This phase of system development can be explained simply by use case diagram
and sequence diagram whereas the implementation design is explained by a flow chart and
screenshots of the implementation as follows

GUI Representation Explained

FIGURE: 4. 4 GUI Representations

The GUI here shows guidance for the user on the screen. The interface shows three buttons
which are used in initializing the camera, processing , checking validity of the input then finally
integrate with the raspberry pi simulation to deliver the service.

33
Machine learning based mask and sanitizer vending machine

After inserting an amount of 5 birr as shown by the camera module, the system

will ask further confirmation by asking the user to press the process button.

The machine will validate the inserted birr which is 5 birr in this scenario and

Dispense the item through the raspberry pi simulation.

FIGURE: 4. 5 GUI of the system with 5 birr

34
Machine learning based mask and sanitizer vending machine

After inserting an amount of 10 birr as shown by the camera module, the system

will ask further confirmation by asking the user to press the process button.

The machine will validate the inserted birr which is 10 birr in this scenario and

Dispense the item through the raspberry pi simulation.


FIGURE: 4. 6 GUI of the system with 10 birr

35
Machine learning based mask and sanitizer vending machine

The 3rd scenario is when the user decides to use plastic bottles as an input and the

Machine takes the same approach to validate if it’s a plastic or not

After validation of the plastic bottles the machine will dispense the previlage of the
items to the customer. In this project it is programmed to dispense 5 birr item which is a mask.

FIGURE: 4. 7 GUI of the system with plastics

36
Machine learning based mask and sanitizer vending machine

FIGURE4. 8 GUI showing invalid input

If any input rather than 5 birr, 10 birr or plastic bottles are inserted into the machine, the machine
will not dispense anything and as it can be seen from the interface it declares it as an invalid
input.

37
Machine learning based mask and sanitizer vending machine

4.2 SIMULATION RESULT


The main simulaton of vending machine which is done on proteus software is as follows.

FIGURE: 4. 9 Simulation Result

The simulation here shows

The LCD displays to choose the item, assuming the customer choose a 5 birr item/ mask, the LCD
displays to insert 5 birr to the customer. This is shown by pressing the 5 birr item1 on the proteus
software.

38
Machine learning based mask and sanitizer vending machine

FIGURE: 4. 10 simulation showing mask dispensing

The simulation here shows

After entering a valid birr of 5, the machine will vend a mask and the LCD displays dispensing mask on
the screen. This process is shown on the proteus software with a switch that denotes the 5 birr which
after being pressed it will give a signal to the raspberry pi that it is a valid 5 birr. After accepting the
money, the led switches on and the motor starts to run showing that it is vending the mask.

39
Machine learning based mask and sanitizer vending machine

vv

FIGURE: 4. 11 simulation showing return of input when invalid

The simulation here shows

This simulation shows that after entering a plastic bottle, the machine will detect the validity of the
plastic and measure the weight. If it is the correct weight set by the system, it will vend mask from the
machine. The LCD also displays that it has detected a plastic bottle.

40
Machine learning based mask and sanitizer vending machine

Test Performed
Tests on functionality based on the requirements made on objectives were made. And the results
were as follows.

TABLE: 4. 1 Test Performed


Summary NO
Total test case 10
Executed 20
Pass 15
Fail 5
Not executed 0

TABLE: 4. 2 Functionality Testing Phase 1


Functional Testing Phase 1
Test case ID Description Press/Fail/Not Test Date
Executed
01 Predicting five birr image class Pass 22/01/2021
02 Predicting ten birr image class Pass 22/01/2021
03 Converting ui design into Fail 22/01/2021
python code
04 Initializing the webcam inside Fail
the GUI
05 Integrating the ui code with the Pass
ML model
06 Resolving model over fitting Fail
problem
07 Predicting plastic bottle class Fail
08 Saving on process image Pass
09 Deleting processed image Pass
10 Writing prediction output into Fail
file

TABLE: 4. 3 Functionality Testing Phase 2

41
Machine learning based mask and sanitizer vending machine

Functional Testing Phase 2


Test case ID Description Press/Fail/Not Test Date
Executed
01 Predicting five birr image Pass
class
02 Predicting ten birr image Pass
class
03 Converting ui design into Pass
python code
04 Initializing the webcam Pass
inside the GUI
05 Integrating the ui code with Pass
the ML model
06 Resolving model over fitting Pass
problem
07 Predicting plastic bottle class Pass
08 Saving on process image Pass
09 Deleting processed image Pass
10 Writing prediction output Pass
into file

42
Machine learning based mask and sanitizer vending machine

FIGURE4. 12 Performance of the system

43
Machine learning based mask and sanitizer vending machine

CHAPTER FIVE

LIMITATIONS AND FUTURE WORKS

LIMITATIONS
The project that has been carried out has limitations of its own which limits the quality. The limitations
that are encountered are:

o The machine is not able to identify if a colored copy of the money was entered
o There was no automatic way of filling the items from the storage into the machine when there
was scarcity. The operator is supposed to open the slots and stuck the items into it.
o If by any case the items get stuck into the spiral rod and failed to deliver while the user ordered
the item, there is no way of detecting whether it is delivered or not.

FUTURE WORKS
There are some alterations that could be done to improve further work. These may include:

o The machine could be designed to operate based on a one-time storage per day to reduce the
hustle for the operator.
o The machine will be more convenient to use if it can accept different kinds of money including
coins.
o The machines feasibility would increase by creating a system whereby the machine differentiates
fake currency notes.

44
Machine learning based mask and sanitizer vending machine

CHAPTER SIX

CONCLUSION AND RECOMMENDATION

CONCLUSION
This project called Machine learning based mask and sanitizer vending machine with plastic
bottle waste disposal system which is used for vending mask and sanitizer by using raspberry,
LCD, relay, obstacle infrared sensor, servo motor and camera is based on machine learning
technology which is one way of developing a system with image processing for the identification
of birr currency note and plastic bottle that is used as input for the vending machine and
integrated with raspberry to vend the mask/sanitizer to the user. The image identification used to
minimize the unnecessary costs of using different sensors for the validation/ assurance of the
correct birr currency into the machine since image processing uses nothing but a code done on a
collected data. The obstacle infrared sensor initiates the camera to capture the inputs photos and
the raspberry validates those input by using image processing. If the image taken is valid input
the obstacle infrared sensor initiate the servo motor to deliver the products based on type of
inputs by the customer otherwise the motor returns the inputs if it is an invalid input.

The machine is helpful since it is convenient, efficient and user friendly to use. It is cost effective
to use compared to other vending machines as the tools used are reduced by way of machine
learning in this project thus providing a better vending method than others. Therefore, this
project successfully met the objective requirements made and aims at developing a system
whereby people’s way of life making it easy and interesting.

45
Machine learning based mask and sanitizer vending machine

RECOMMENDATION
This project paper benefits the end-user since it is user friendly to use and has a guidance on
what to do next through the screen. Since it operates on a 24 hour basis without the involvement
of an operator, it is beneficial. It will also benefit the end-user since the items will be free from
any contagion and reduces handling of the items hand by hand creating a healthy environment. It
has variety of options and saves time as well as money for the customer.

Further improvements could be made to make the project more feasible. Finding a systematic
approach which can refill the items from a set of large stacked storage room would create a less
hustling working environment for both the operator and user. As it is mentioned the machine
operates at any time needing a convenient security system to be protected from theft. It could
also be improved by adding a feature which can identify fake currency notes. we recommend
further work to be done by accepting all currency notes including the coins and by creating a
database the operator to easily know the profit as well as the overhead.

46
Machine learning based mask and sanitizer vending machine

REFERENCES

[1] "Wikipedia," 25 November 2020. [Online]. Available:


https://en.wikipedia.org/wiki/Vending_machine. [Accessed 25 november 2020].

[2] "A History of Vending Machines," 05 Mar 2020. [Online]. Available:


https://camelbackvending.com/history-vending-machines-2/.

[3] B. Samantray, "Implementation of an automatic chocolate vending machine based on RFID and
arduino uno," vol. 12, no. 12, p. 5, 2019.

[4] T. S. W. N. J. Vishal, "Medicine dispensing machine using raspberry pi and arduino controller," p. 50,
2017.

[5] R. S. D. M. e. e. Shweta Dour, "Vending Machine Using 8051 Microcontroller," vol. 6, no. 05, p. 188,
2017.

[6] G. M. M. M. S. e. e. D V Raagu, "Design and fabrication of coin operated portable water vending
machine," India, 2016-2017, p. 43.

[7] K. R. e. e. K.R.Nimisha, "Smart Newspaper vending machine," Asian Journal of A pplied science and
Technology , vol. 1, no. 1, p. 136, 2017.

[8] "wikipedia," 21 jan 2021. [Online]. Available: https://en.wikipedia.org/wiki/Qt_(software). [Accessed


22 jan 2021].

[9] "wikipedia," 15 12 2020. [Online]. Available: https://docs.microsoft.com/en-us/azure/cognitive-


services/custom-vision-service/overview. [Accessed 18 jan 2021].

47
Machine learning based mask and sanitizer vending machine

APPENDICES
RASPBERRY PI SIMULATION

# Modules D5 = 22

from goto import * D6 = 27

import time D7 = 18

import var lcd_columns = 16

import pio lcd_rows = 2

import RPi.GPIO as GPIO def peripheral_setup () :

import resource # Peripheral Constructors

import sys pass

import os def peripheral_loop () :

import subprocess pass

#subprocess.Popen('C:/Users/Israel/Desktop/ID #---CONFIG_END---
EA-PythonProjects/try/try1.py')
# Main function
#import reader
def main () :
# make sure you update the address below
# Setup
# sys.path.insert(1, '<simulate initial files
address in your PC>') peripheral_setup()

sys.path.insert(1, lcd = LCD.Adafruit_CharLCD(rs, en, D4, D5,


'C:/Users/Israel/Documents/Proteus D6, D7, lcd_columns, lcd_rows)
Projects/rasberry simulations/vending motor1 = 5 #mask
rasberry/RaspberryPI_LCD_intial_files')
motor2 = 6 #valid birr
import CharLCD as LCD
motor2_1 = 7 #Not valid plastic
import datetime
motor3 = 4 #sanitizer
rs = 19
#motor4 = 17 #item input
en = 20
motor5 = 10 #valid plastic
D4 = 23

48
Machine learning based mask and sanitizer vending machine

motor5_1 = 13 #Not valid plastic GPIO.setup(button5,GPIO.IN)

switch1= 26 #select 10 birr sanitizer GPIO.setup(motor1,GPIO.OUT)

switch2 = 8 #select 5 birr mask GPIO.setup(motor2,GPIO.OUT)

button1=24 #valid 5 birr inserting GPIO.setup(motor2_1,GPIO.OUT)

button2=25 #valid 10 birr inserting GPIO.setup(motor3,GPIO.OUT)

button3=12 #invalid birr inserting #GPIO.setup(motor4,GPIO.OUT)

button4=21 #valid weight GPIO.setup(motor5,GPIO.OUT)

button5=16 #invalid weight GPIO.setup(motor5_1,GPIO.OUT)

irP = 14 #plastic bottle detection

irB = 11 #birr detection lcd.message("Welcome to our\nVending


Machine")
Pswitch1=15
time.sleep(1)
Pswitch2=2
lcd.clear()
Pswitch3=3
lcd.message("Thanks for..\nChoosing us")
Pswitch4= 9
time.sleep(1)
GPIO.setmode(GPIO.BCM)
lcd.clear()
GPIO.setwarnings(False)
lcd.message("Plastic Bottle..\nVending
GPIO.setup(switch1,GPIO.IN) Machine")
GPIO.setup(switch2,GPIO.IN) time.sleep(1)
GPIO.setup(Pswitch1,GPIO.IN) lcd.clear()
GPIO.setup(Pswitch2,GPIO.IN) def PswitchOFF():
GPIO.setup(Pswitch3,GPIO.IN) lcd.message("Please insert\nPlastic bottle")
GPIO.setup(Pswitch4,GPIO.IN) time.sleep(2)
GPIO.setup(button1,GPIO.IN) lcd.clear()
GPIO.setup(button2,GPIO.IN) GPIO.input(15) ==0
GPIO.setup(button3,GPIO.IN) GPIO.input(2) ==0
GPIO.setup(button4,GPIO.IN) GPIO.input(3) ==0

49
Machine learning based mask and sanitizer vending machine

GPIO.input(9) ==0 lcd.clear()

pass pass

#def inputMotor(): def MaskMotorON():

#lcd.message("Inputing Item...") lcd.message("Dispensing...\n...Mask...")

#GPIO.output(17, GPIO.HIGH) GPIO.output(motor1,GPIO.HIGH)

#time.sleep(1) time.sleep(1)

#lcd.clear() lcd.clear()

#pass pass

def irBirrOFF(): def SanitizerMotorON():

lcd.message("...No item..\n..is Detected") lcd.message("Dispensing...\nSanitizet")

time.sleep(1) GPIO.output(motor3,GPIO.HIGH)

lcd.clear() time.sleep(1)

pass lcd.clear()

def irPlasticOFF(): pass

lcd.message("No item\n..is Detected") def Pswitch1ON():

time.sleep(1) lcd.message("specified weight\nnot


reached")
lcd.clear()
time.sleep(1)
pass
lcd.clear()
def irPlasticON():
pass
lcd.message("...Item...\n Detected")
def Pswitch2ON():
time.sleep(1)
lcd.message("specified weight\nnot
lcd.clear() reached")
pass time.sleep(1)
def irBirrON(): lcd.clear()
lcd.message("..Item..\n Detected") pass
time.sleep(1) def Pswitch3ON():

50
Machine learning based mask and sanitizer vending machine

lcd.message("specified weight\nnot lcd.clear()


reached")
pass
time.sleep(1)
def MaskON():
lcd.clear()
GPIO.output(motor1, GPIO.HIGH)
pass
GPIO.output(motor2,GPIO.LOW)
def Pswitch4ON():
GPIO.output(motor2_1,GPIO.LOW)
lcd.message("specified weight\ is reached")
GPIO.output(motor3,GPIO.LOW)
time.sleep(1)
#GPIO.output(motor4,GPIO.LOW)
lcd.clear()
GPIO.output(motor5,GPIO.LOW)
pass
GPIO.output(motor5_1,GPIO.LOW)
def button4ON():
pass
lcd.message("Checking Weight\nPlease
Wait...") def SanitizerON():

time.sleep(1) GPIO.output(motor1,GPIO.LOW)

lcd.clear() GPIO.output(motor2,GPIO.LOW)

lcd.message("You have entered\nValid GPIO.output(motor2_1,GPIO.LOW)


Weight...") GPIO.output(motor3,GPIO.HIGH)
time.sleep(1) #GPIO.output(motor4,GPIO.LOW)
lcd.clear() GPIO.output(motor5,GPIO.LOW)
pass GPIO.output(motor5_1,GPIO.LOW)
def button5ON(): pasS
lcd.message("Checking Weight\nPlease def lcdSantizer():
Wait...")
lcd.message("Dispensing...\nSanitizer..")
time.sleep(1)
GPIO.output(4, GPIO.LOW)
lcd.clear()
time.sleep(1)
lcd.message("Invalid Weight..\nInsert
More") lcd.clear()

time.sleep(1) pass

51
Machine learning based mask and sanitizer vending machine

#def lcdItemInput(): lcd.message("InValid Input\nPlease Try


Again")
#lcd.message("...Item...\n...Inputing..")
GPIO.output(7, GPIO.LOW)
#GPIO.output(17, GPIO.LOW)
time.sleep(1)
#time.sleep(1)
lcd.clear()
#lcd.clear()
pass
#pass
# Infinite loop
def lcdMask():
while 1:
lcd.message("Dispensing...\nMask..")
peripheral_loop()
GPIO.output(5, GPIO.LOW)
if GPIO.input(8) ==1:
time.sleep(1)
button1ON()
lcd.clear()
if GPIO.input(24) ==1 and GPIO.input(11)
pass ==1:
def lcdSanitizer(): irBirrON()
lcd.message("Dispensing...\nSanitizer") processValidBirr()
GPIO.output(4, GPIO.LOW) MaskMotorON()
time.sleep(1) lcdMask()
lcd.clear() #inputMotor()
pass #lcdItemInput()
def lcdNotvalidPlastic(): main()
lcd.message("InValid Input\nPlease Try elif GPIO.input(12) ==1 and
Again") GPIO.input(11) ==1:
GPIO.output(13, GPIO.LOW) irBirrON()
time.sleep(1) button3ON()
lcd.clear() processINValidBirr()
pass lcdNotValidBirr()

main()
def lcdNotValidBirr(): elif GPIO.input(26) ==1:

52
Machine learning based mask and sanitizer vending machine

button2ON() button4ON()

if GPIO.input(25) ==1 and GPIO.input(11) processValidPlastic()


==1:
MaskMotorON()
irBirrON()
lcdMask()
processValidBirr()
#inputMotor()
SanitizerMotorON()
#lcdItemInput()
lcdSanitizer()
#time.sleep(1)
#inputMotor()
main()
#lcdItemInput()
elif GPIO.input(16) == 1:
main ()
button5ON()
elif GPIO.input(12) ==1 and
GPIO.input(11) ==1: processINValidPlastic()

irBirrON() lcdNotvalidPlastic()

button3ON() #time.sleep(1)

processINValidBirr() main()

lcdNotValidBirr() elif GPIO.input(15) ==1 and GPIO.input(14)


==1:
main ()
irPlasticON()
elif GPIO.input(8) == 0 and
GPIO.input(26)==0 and GPIO.input(11)== 0: Pswitch1ON()

AllOFF() pass

lcdNOT() elif GPIO.input(2) ==1 and GPIO.input(14)


==1:
pass
irPlasticON()
if GPIO.input(15) ==1 and GPIO.input(2)
==1 and GPIO.input(3) ==1 and GPIO.input(9) Pswitch2ON()
==1 and GPIO.input(14) ==1: pass
irPlasticON() elif GPIO.input(3) ==1 and GPIO.input(14)
CheckWait() ==1:

if GPIO.input(21) == 1: irPlasticON()

Pswitch3ON()

53
Machine learning based mask and sanitizer vending machine

pass irPlasticOFF()

elif GPIO.input(9) ==1 and GPIO.input(14) PswitchOFF()


==1:
pass
irPlasticON()
# Command line execution
Pswitch4ON()
if __name__ == '__main__' :
pass
main()
elif GPIO.input(14) == 0:

54
Machine learning based mask and sanitizer vending machine

GUI python Code

import sys cap =cv2.VideoCapture(0)

import numpy as np #while (True):

import cv2 #print(cap.read())

from PyQt5 import QtCore while(cap.isOpened()):

from PyQt5.QtCore import pyqtSlot ret, frame=cap.read()

from PyQt5.QtGui import QImage , QPixmap if ret==True:

from PyQt5.QtWidgets import QMainWindow, self.displayImage(frame,1)


QDialog , QApplication, QLabel
cv2.waitKey()
from PyQt5.uic import loadUi
if (self.logic==2):
class tehseencode(QDialog):
self.value=self.value+1
def __init__(self):

super(tehseencode,self).__init__() cv2.imwrite("/home/grace/Pictures/camfeed/%s.
png"%(self.value),frame)
# loadUi("student3.ui",self)
self.logic = 1
loadUi("untitled1.ui",self)
self.TEXT.setText('Invalid Input or
self.logic = 0 no input is detected')
self.value = 1 cap.release()
self.SHOW.clicked.connect(self.onClicked) cv2.destroyAllWindows()
self.TEXT.setText("Dear customer press else:
start to purchase, make sure you inserted money
unfolded") print('not found')

# cap.release()
self.CAPTURE.clicked.connect(self.CaptureClic
ked) # cv2.destroyAllWindows()

@pyqtSlot() def CaptureClicked(self):

def onClicked(self): self.logic=2

self.TEXT.setText('Kindly Press "Process"


to confirm your purchase') def displayImage(self,img,window=1):

55
qformat=QImage.Format_Indexed8

if len(img.shape)==3:

if(img.shape[2])==4:

qformat=QImage.Format_RGBA888

else:

qformat=QImage.Format_RGB888

img =
QImage(img,img.shape[1],img.shape[0],qformat
)

img = img.rgbSwapped()

self.imgLabel.setPixmap(QPixmap.fromImage(i
mg))

self.imgLabel.setAlignment(QtCore.Qt.AlignHC
enter | QtCore.Qt.AlignVCenter)

app = QApplication(sys.argv)

window=tehseencode()

window.show()

try:

sys.exit(app.exec_())

except:

print('excitng')

You might also like