Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
278 views

Final Minor Report

This document is a minor project report on a coin detection based mobile charging system submitted in partial fulfillment of the requirements for a Bachelor of Technology degree. The project uses coin detection through image processing to determine the charging time for a mobile phone. An Arduino board controls a relay module to provide power to charge a mobile phone for a predetermined time based on the detected coin value. The overall goal is to provide economical mobile charging at locations where people congregate.

Uploaded by

Aman Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
278 views

Final Minor Report

This document is a minor project report on a coin detection based mobile charging system submitted in partial fulfillment of the requirements for a Bachelor of Technology degree. The project uses coin detection through image processing to determine the charging time for a mobile phone. An Arduino board controls a relay module to provide power to charge a mobile phone for a predetermined time based on the detected coin value. The overall goal is to provide economical mobile charging at locations where people congregate.

Uploaded by

Aman Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 39

(Annexure I)

A Minor Project Report


on
COIN DETECTION BASED MOBILE CHARGING
SYSTEM

Submitted in partial fulfillment of requirements for the award of the

Degree of
Bachelor of Technology
In
Electronics and Communication

Under the guidance of


Dr. Garima Shrivastav
(Assistant Professor, AIACTR)
Submitted By
PRATEEK GOYAL TUSHAR RASTOGI
(02610102814) (04510102814)

ABHISHEK GHAI MAYANK SHARMA


(05010102814) (08710102814)

DEPARTMENT OF ELECTRONICS AND COMMUNICATION

AMBEDKAR INSTITUTE OF ADVANCED COMMUNICATION


TECHNOLOGIES AND RESEARCH
GEETA COLONY, DELHI
November, 2017

-1-
(Annexure II)

CANDIDATE’S DECLARATION

I hereby declare that the work presented in this report entitled “Coin Detection Based Mobile
Charging System”, in fulfillment of the requirement for the award of the degree Bachelor of
Technology in Electronics and Communication, submitted in ECE Department, AIACTR
affiliated to Guru Gobind Singh Indraprastha University, New Delhi, is an authentic record of
my own work carried out during my degree under the guidance of Dr. Garima Shrivastav.

The work reported in this has not been submitted by me for award of any other degree or
diploma.

Date :

Place :

-2-
(Annexure III)

CERTIFICATE

This is to certify that the Project work entitled “Coin Detection Based Mobile Charging System” submitted
by Prateek Goyal, Tushar Rastogi, Abhsihek Ghai and Mayank Sharma in fulfillment for the requirements of
the award of Bachelor of Technology Degree in Electronics and Communication at AIACTR, New Delhi is
an authentic work carried out by his/her under my supervision and guidance. To the best of my knowledge,
the matter embodied in the project has not been submitted to any other University / Institute for the award of
any Degree .

Date: Dr. Garima Shrivastav

(Asst. Prof., ECE)

-3-
(Annexure IV)

ACKNOWLEDGEMENT

I express my sincere gratitude to Dr. RK Sharma (HOD,ECE) and Dr. Garima Shrivastav
(A.P,ECE), for their valuable guidance and timely suggestions during the entire duration of my
dissertation work, without which this work would not have been possible. I would also like to
convey my deep regards to all other faculty members of school of ECE, who have bestowed their
great effort and guidance at appropriate times without which it would have been very difficult on
my part to finish this work. Finally I would also like to thank my friends for their advice and
pointing out my mistakes.

-4-
ABSTRACT

In today’s generation, the need for mobile phones is growing exponentially. As we know that mobile phones
are an irreplaceable component of present society, not only they are a source of entertainment but they are
also a big boon to those who are in dire need of help. But the major challenge for mobile phone
manufacturers is their woeful battery problems. So to combat with this problem, we have designed an
efficient, economical and ready-to-go solution for the benefit of people. The aim of the project is to install
these vending machine type installations to charge the mobile phones at a very economical cost.

This solution can be utilized at Airports, Exhibition Centers, Markets, Conference Halls, Rest Stops,
Stadiums, Bus stops etc where people are present in a large number. The idea is also to create an app which
can be used to find a nearby installation of this machine.

-5-
CONTENTS

1. Introduction ...................................................................................... 1
2. Candidate’s Declaration .................................................................. 2
3. Certificate ......................................................................................... 3
4. Acknowledgement ........................................................................... 4
5. Abstract ............................................................................................ 5
6. Introduction ..................................................................................... 7
7. Components Used ........................................................................... 8 - 13
8. Electrical Connections ................................................................... 14
9. Plan and Design .............................................................................. 15 - 16
10. Algorithms/Block Diagrams .......................................................... 17 - 18
11. Project Code .................................................................................... 19 - 36
12. Future Scope .................................................................................... 37
13. Conclusion ........................................................................................ 38
14. References ........................................................................................ 39

-6-
INTRODUCTION

Electricity plays a pivotal role in our life. It forms the backbone of every electronic gadget. One such gadget
is mobile phone. But most of them come with very poor battery life. Through this project we are trying to
address a solution to this problem. Mobile charging vending machines can be installed at every corner of
road and can provide a solution to the stressed techies and needy citizens.

It first takes the image of coins, then with the help of image processing algorithms on MATLAB, this
processed information is sent to the microcontroller. As soon as microcontroller receives the image
processing output, it initiates an interrupt and puts its timer into process. The value of currency signifies the
time duration for which it needs to be charged. The power supply from microcontroller will charge the
device for a predetermined time. Once the time is up, the circuit breaks and the person can take back
charged mobile with a happy and satisfied smile.

This can be of at most importance in rural areas, bus stops, highways etc. Successful implementation of this
project will ensure safety, confidence in the minds of digitally growing population.

-7-
COMPONENTS USED

HARDWARE SPECIFICATIONS:

 Arduino Uno
 LCD Display (16x2)
 Relay Module (6 volts)
 HP Webcam
 Mobile Charger
 LEDs
 Buzzer
 DC Adapter
 Breadboard and Wires
 Multimeter

SOFTWARE SPECIFICATIONS:

 Arduino IDE
 MATLAB

-8-
1. Arduino Board

Arduino is an open-source platform used for building electronics


projects. Arduino consists of both a physical programmable circuit
board (often referred to as a microcontroller) and a piece of software, or
IDE (Integrated Development Environment) that runs on your computer,
used to write and upload computer code to the physical board.
The Arduino platform has become quite popular with people just
starting out with electronics, and for good reason. Unlike most previous
programmable circuit boards, the Arduino does not need a separate
piece of hardware (called a programmer) in order to load new code onto the board – you can simply use a
USB cable. Additionally, the Arduino IDE uses a simplified version of C++, making it easier to learn to
program. Finally, Arduino provides a standard form factor that breaks out the functions of the micro-
controller into a more accessible package.

Features of the Arduino UNO:


 Microcontroller: ATmega328
 Operating Voltage: 5V
 Input Voltage (recommended): 7-12V
 Input Voltage (limits): 6-20V
 Digital I/O Pins: 14 (of which 6 provide PWM output)
 Analog Input Pins: 6
 DC Current per I/O Pin: 40 mA
 DC Current for 3.3V Pin: 50 mA
 Flash Memory: 32 KB of which 0.5 KB used by bootloader
 SRAM: 2 KB (ATmega328)
 EEPROM: 1 KB (ATmega328)
 Clock Speed: 16 MHz

-9-
2. LCD Display

LCD stands for liquid crystal display. Character and graphical


LCDs are most common among hobbyist and DIY electronic
circuit/project makers. Since their interface serial/parallel pins
are defined so its easy to interface them with many
microcontrollers. Many products we see in our daily life have
lcd's with them. They are used to show status of the product or
provide interface for inputting or selecting some process.
Washing machine, microwave,air conditioners and mat cleaners
are few examples of products that have character or graphical LCDs installed in them.
Character LCDs come in many sizes 8x1, 8x2, 10x2, 16x1, 16x2, 16x4, 20x2, 20x4, 24x2, 30x2, 32x2, 40x2
etc. Many multinational companies like Philips, Hitachi, Panasonic make their own custom type of character
LCDs to be used in their products. All character LCDs performs the same functions(display characters,
numbers, special characters, ASCII characters etc). Their programming is also very much the same and they
all have same 14 pins (0-13) or 16 pins (0 to 15).

In an MxN LCD, M denotes number of columns and N represents number of rows. Like if the LCD is
denoted by 16x2, it means it has 16 columns and 2 rows.

3. Relay

A relay is an electrically operated switch. Current flowing through


the coil of the relay creates a magnetic field which attracts a lever
and changes the switch contacts. The coil current can be on or off so
relays have two switch positions and most have double throw
(changeover) switch contacts as shown in the diagram.
Relays allow one circuit to switch a second circuit which can be
completely separate from the first. For example a low voltage
battery circuit can use a relay to switch a 230V AC mains circuit. There is no electrical connection inside the
relay between the two circuits, the link is magnetic and mechanical.

The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it can be as much as
- 10 -
100mA for relays designed to operate from lower voltages. Most ICs cannot provide this current and a
transistor is usually used to amplify the small IC current to the larger value required for the relay coil.

The relay's switch connections are usually labelled COM, NC and NO:
 COM = Common, always connect to this, it is the moving part of the switch.
 NC = Normally Closed, COM is connected to this when the relay coil is off.
 NO = Normally Open, COM is connected to this when the relay coil is on.
Connect to COM and NO if you want the switched circuit to be on when the relay coil is on.
Connect to COM and NC if you want the switched circuit to be on when the relay coil is off.

4. Webcam

A webcam is a video camera that feeds or streams its image in real time to
or through a computer to a computer network. When "captured" by the
computer, the video stream may be saved, viewed or sent on to other
networks via systems such as the internet, and emailed as an attachment.
When sent to a remote location, the video stream may be saved, viewed or
on sent there. Unlike an IP camera (which connects using Ethernet or
WiFi), a webcam is generally connected by a USB cable, or similar cable, or built into computer hardware,
such as laptops.

Webcams typically include a lens, an image sensor, support electronics, and may also include a microphone
for sound. Various lenses are available, the most common in consumer-grade webcams being a plastic lens
that can be screwed in and out to focus the camera. Fixed-focus lenses, which have no provision for
adjustment, are also available. As a camera system's depth of field is greater for small image formats and is
greater for lenses with a large f-number (small aperture), the systems used in webcams have a sufficiently
large depth of field that the use of a fixed-focus lens does not impact image sharpness to a great extent.
The most popular use of webcams is the establishment of video links, permitting computers to act as
videophones or video conference stations. Other popular uses include security surveillance, computer vision,
video broadcasting, and for recording social videos.

5. Mobile Charger
- 11 -
A mobile battery charger circuit is a device that can automatically
recharge a mobile phone’s battery when the power in it gets low.
Nowadays mobile phones have become an integral part of everyone’s
life and hence require frequent charging of battery owing to longer
duration usage.

Battery chargers come as simple, trickle, timer based, intelligent,


universal battery charger-analyzers, fast, pulse, inductive, USB based,
solar chargers and motion powered chargers. These battery chargers
also vary depending on the applications like mobile phone charger, battery charger for vehicles, electric
vehicle batteries chargers and charge stations.

Charging methods are classified into two categories: fast charge method and slow charge method. Fast
charge is a system used to recharge a battery in about two hours or less than this, and the slow charge is a
system used to recharge a battery throughout the night. Slow charging is advantageous as it does not require
any charge detection circuit. Moreover, it is cheap as well. The only drawback of this charging system is that
it takes maximum time to recharge a battery.

6. Breadboard and Wires


A breadboard is a construction base for
prototyping of electronics. Originally it was
literally a bread board, a polished piece of wood
used for slicing bread. In the 1970s the solderless
breadboard (AKA plugboard, a terminal array
board) became available and nowadays the term
"breadboard" is commonly used to refer to these.
Because the solderless breadboard does not
require soldering, it is reusable. This makes it
easy to use for creating temporary prototypes and
experimenting with circuit design. For this reason, solderless breadboards are also extremely popular with
students and in technological education. Older breadboard types did not have this property. A stripboard
(Veroboard) and similar prototyping printed circuit boards, which are used to build semi-permanent soldered

- 12 -
prototypes or one-offs, cannot easily be reused. A variety of electronic systems may be prototyped by using
breadboards, from small analog and digital circuits to complete central processing units (CPUs).

7. Multimeter

Multimeter is used in various phases of the project for testing resistance of


various components,and to check the required voltage and current values
across components.
A multimeter is has three parts:
 Display
 Selection Knob
 Ports
The display usually has four digits and the ability to display a negative
sign. A few multimeters have illuminated displays for better viewing in
low light situations.
The selection knob allows the user to set the multimeter to read different things such as milliamps (mA) of
current, voltage (V) and resistance (Ω).
Two probes are plugged into two of the ports on the front of the unit. COM stands for common and is almost
always connected to Ground or ‘-’ of a circuit. The COM probe is conventionally black but there is no
difference between the red probe and black probe other than color. 10A is the special port used when
measuring large currents (greater than 200mA). mAVΩ is the port that the red probe is conventionally
plugged in to. This port allows the measurement of current (up to 200mA), voltage (V), and resistance (Ω).
The probes have a banana type connector on the end that plugs into the multimeter. Any probe with a
banana plug will work with this meter. This allows for different types of probes to be used.

- 13 -
ELECTRICAL CONNECTIONS

1. Arduino LCD Connections

2. Arduino Relay Connections

- 14 -
PLAN AND DESIGN

Before the proceeding with design and implementation of this project certain points should be noted. For
example the positioning of the camera should be selected appropriately. If not taken care off it would result
in detection of circular coin as elliptical and hence entire process would be a waste. So camera should be
setup at proper height and angle. At a given instant only one coin can be inserted. If we try to insert a
number of coins simultaneously, overlapping of coins will take place and image processing algorithm will
not give desired outcome.

1. Detection of Coins
The implementation of coin detection can be done in several ways. Some of them are listed below:
i. Electromagnetic based system
ii. Sensor based system
iii. Use of image processing algorithms

i. The electromagnetic method makes use of a coil carrying current, which acts as a solenoid. When a coin
passes through it, the coin disturbs the magnetic field in different ways as different coins have different
mass and dimensions. Thus, we can calculate the amount of disturbance in the magnetic field, which
gives us the mass of the coin. Then the coin passes through a infrared emitter and receiver, which can
give us the radius of the coin. This is the same mechanism which is used in the vending machines.
ii. The sensor based system uses a load sensor which can calculate the amount of weight of coin kept on it.
But the major drawback of this system is that it cannot differentiate between different materials of the
coin. For example, it cannot distinguish between two coins having same physical dimensions, but
having different compositions.
iii. For the image processing technique, the real time image of the coin(s) is scanned using a
mountable camera. The appropriate computation strategy uses the object polarity and sensitivity
to determine a range matrix for various coins. According to the algorithm, the captured image is
matched with the computed range matrix. The value(s) of the coin is then indicated to the
microcontroller for further processing.

- 15 -
2. Use of Microcontroller
 The output of the image processing stage is fed to the microcontroller, for further processing.
 After reception of the value of the coin, the microcontroller puts its timer into operation. It then charges
the mobile phone for a pre-determined time as set during the initialization of the microcontroller. As
soon as the timer, times out the interrupt resets the whole stage and the mobile phone can be removed
safely. It is now ready to accept another coin and repeat the same procedure.
 The above procedure can be illustrated by a simple example. Suppose, user X inserts a coin of
denomination ₹ 5, the mounted camera captures the image and from this image, the value of the coin is
detected. This extracted value is then sent to the microcontroller for further computations. The mobile is
then charged for a specified time like 20 or 30 minutes.

3. Circuit Designing
 The rectifier stage is designed on a PCB with input AC supply from a socket or a Solar Panel. This input
is then fed to the transformer for the AC-DC conversion. The output is then filtered with the help of
diodes and the DC output is used to power the microcontroller stage.
 The microcontroller stage is integrated with a LCD display for displaying of time and some other
parameters. Also, relay is connected for timing synchronization of the charging circuit.

4. Assembling and Debugging


At this stage, all the components are integrated either on a breadboard or a PCB according to the schematics
of the circuitry. After assembling all the components, testing is performed on the whole system or various
individual units.
After the testing stage, debugging is performed on the whole installation. If there is any undesired output,
the individual stages are then tested again for any loose electrical connections(technical snags) or any logical
error in the designed codes(software error).

- 16 -
ALGORITHMS / BLOCK DIAGRAMS

The various algorithms used in this project are explained below:

1. Image Processing
 Image is captured using a camera.
 This image is then converted from RGB to Grayscale.
 The radius and the center of the coin are found by using different MATLAB commands and then a
circle enclosing the coin is traced.
 The image of a coin is then cropped by passing the parameters i.e., diameter on the x and y-axes.
 The output of the radius value from the above step is then passed into another function file, which has
the radius of various coins stored already for comparison.
 In the output figure, the cropped image with its radius value is displayed.

- 17 -
2. Embedded Systems
 The microcontroller receives the detected value on Serial COM port.
 It then starts its processing for timer interrupts and displays it on a LCD display.
 After the specified time, the user can safely remove his/her phone.

- 18 -
PROJECT CODE

1. MATLAB CODE
 main.m
clear all;
close all;

% Start the webcam


cam = webcam(1);
img = snapshot(cam);
imshow(img);

% this is where and what your image will be saved


%counter = 1;
baseDir = '/home/prateek/Documents/MATLAB/Minor Project Code/';
baseName = 'image';
newName = fullfile(baseDir, sprintf('%s.jpg', baseName));
%newName = [baseDir baseName '.jpg'];
%while exist(newName,'file')
% counter = counter + 1;
% newName = [baseDir baseName num2str(counter) '.jpg'];
%end
imwrite(img, newName);

%savepath = '/home/prateek/Documents/MATLAB/Minor Project Code';


%nametemplate = 'img.jpg';

- 19 -
rgb = imread('/home/prateek/Documents/MATLAB/Minor Project Code/image.jpg');
figure
imshow(rgb);

d = imdistline;
delete(d);

%Image Conversion, Thresholding and creating circles around the coins


gray_image = rgb2gray(rgb);
imshow(gray_image);
[centres, radii] = imfindcircles(rgb, [75 110], 'ObjectPolarity', 'dark', 'Sensitivity', 0.979);
imshow(rgb)
h = viscircles(centres, radii);
length(centres);

% Finding the radii of the coins


r = round(radii(1)+1);
x = round(centres(1,1))-r;
y = round(centres(1,2))-r;
d = 2*r;
I = imcrop(rgb, [x y d d]);
figure
imshow(I)
title(['Radius: ' num2str(radii(1)) 'px']);
value = radiif(radii(1));
disp(value);

% Arduino Communication
arduino=serial('/dev/ttyACM0','BaudRate',9600);
fopen(arduino);
fprintf(arduino, '%d', value);
fclose(arduino);

clear('cam');

- 20 -
 radiif.m
% Find the value of the coin by passing the radius value
function f = radiif(rad)

if rad>=75 && rad<=86


f = 5;
elseif rad>=95 && rad<=106
f = 2;
elseif rad>=86.01 && rad<=94
f = 1;
else
f = 0;
end

2. ARDUINO CODE
 Countimer.cpp
#include "Countimer.h"
#include "Arduino.h"

Countimer::Countimer()
{
_previousMillis = 0;
_currentCountTime = 0;
_countTime = 0;
_isCounterCompleted = false;
_isStopped = true;
_countType = COUNT_NONE;
_startCountTime = 0;
}

Countimer::~Countimer()
{
}

- 21 -
void Countimer::setCounter(uint16_t hours, uint8_t minutes, uint8_t seconds, CountType countType,
timer_callback onComplete)
{
_onComplete = onComplete;
_countType = countType;
setCounter(hours, minutes, seconds);
}

void Countimer::setCounter(uint16_t hours, uint8_t minutes, uint8_t seconds)


{
if (hours > COUNTIMER_MAX_HOURS) {
hours = COUNTIMER_MAX_HOURS;
}

if (minutes > COUNTIMER_MAX_MINUTES_SECONDS) {


minutes = COUNTIMER_MAX_MINUTES_SECONDS;
}

if (seconds > COUNTIMER_MAX_MINUTES_SECONDS) {


seconds = COUNTIMER_MAX_MINUTES_SECONDS;
}

_currentCountTime = ((hours * 3600L) + (minutes * 60L) + seconds) * 1000L;


_countTime = _currentCountTime;

if (_countType == COUNT_UP)
{
// if is count up mode, we have to start from 00:00:00;
_currentCountTime = 0;
}

_startCountTime = _currentCountTime;
}

- 22 -
void Countimer::setInterval(timer_callback callback, uint32_t interval)
{
_interval = interval;
_callback = callback;
}

uint16_t Countimer::getCurrentHours()
{
return _currentCountTime / 1000 / 3600;
}

uint8_t Countimer::getCurrentMinutes()
{
return _currentCountTime / 1000 % 3600 / 60;
}

uint8_t Countimer::getCurrentSeconds()
{
return _currentCountTime / 1000 % 3600 % 60 % 60;
}

char* Countimer::getCurrentTime()
{
sprintf(_formatted_time, "%02d:%02d:%02d", getCurrentHours(), getCurrentMinutes(),
getCurrentSeconds());
return _formatted_time;
}

bool Countimer::isCounterCompleted()
{
return _isCounterCompleted;
}

- 23 -
bool Countimer::isStopped()
{
return _isStopped;
}

void Countimer::start()
{
_isStopped = false;
if(_isCounterCompleted)
_isCounterCompleted = false;
}

void Countimer::pause()
{
_isStopped = true;
}

void Countimer::stop()
{
_isStopped = true;
_isCounterCompleted = true;
_currentCountTime = _countTime;

if(_countType == COUNT_UP)
{
_currentCountTime = 0;
}
}

void Countimer::restart()
{
_currentCountTime = _startCountTime;
_isCounterCompleted = false;
_isStopped = false;
start();
}
- 24 -
void Countimer::run()
{
// timer is running only if is not completed or not stopped.
if (_isCounterCompleted || _isStopped)
return;

if (millis() - _previousMillis >= _interval) {

if (_countType == COUNT_DOWN)
{
countDown();
}
else if (_countType == COUNT_UP)
{
countUp();
}
else
{
callback();
}
_previousMillis = millis();
}
}

void Countimer::countDown()
{
if (_currentCountTime > 0)
{
callback();
_currentCountTime -= _interval;
}
else
{
stop();
complete();
}
- 25 -
}

void Countimer::countUp()
{
if (_currentCountTime < _countTime)
{
callback();
_currentCountTime += _interval;
}
else
{
stop();
complete();
}
}

void Countimer::callback()
{
if(_callback != NULL)
_callback();
}

void Countimer::complete()
{
if(_onComplete != NULL)
_onComplete();
}

 Countimer.h
- 26 -
#pragma once

#ifndef COUNTIMER_H
#define COUNTIMER_H

#if defined(ARDUINO) && ARDUINO >= 100


#include <Arduino.h>
#else
#include <WProgram.h>
#endif

#define COUNTIMER_MAX_HOURS 999


#define COUNTIMER_MAX_MINUTES_SECONDS 59

typedef void(*timer_callback)(void);

class Countimer
{
public:
Countimer();
~Countimer();

enum CountType
{
COUNT_NONE = 0,
COUNT_UP = 1,
COUNT_DOWN = 2
};

// Set up counter time(hours, minutes, seconds), count mode and function to execute if count is
completed.
void setCounter(uint16_t hours, uint8_t minutes, uint8_t seconds, CountType countType,
timer_callback onComplete);

// Set up counter time(hours, minutes, seconds) for existing timer.


void setCounter(uint16_t hours, uint8_t minutes, uint8_t seconds);
- 27 -
// Returns timer's current hours.
uint16_t getCurrentHours();

// Returns timer's current minutes.


uint8_t getCurrentMinutes();

// Returns timer's current seconds.


uint8_t getCurrentSeconds();

void setInterval(timer_callback callback, uint32_t interval);

// Returns current timer as formatted string HH:MM:SS


char* getCurrentTime();

// Returns true if counter is completed, otherwise returns false.


bool isCounterCompleted();

// Returns true if counter is still running, otherwise returns false.


bool isCounterRunning();

// Returns true if timer is stopped, otherwise returns false.


bool isStopped();

// Run timer. This is main method.


// If you want to start timer after run, you have to invoke start() method.
void run();

// Starting timer.
void start();

// Stopping timer.
void stop();

// Pausing timer.
- 28 -
void pause();

// Restart timer.
void restart();

private:
// Counting up timer.
void countDown();

void callback();
void complete();

// Counting down timer.


void countUp();

uint32_t _interval = 1;
uint32_t _previousMillis;

// Stores current counter value in milliseconds.


uint32_t _currentCountTime;
uint32_t _startCountTime;

// Stores cached user's time.


uint32_t _countTime;

// Function to execute.
timer_callback _callback;

// Function to execute when timer is complete.


timer_callback _onComplete;
bool _isCounterCompleted;
bool _isStopped;
char _formatted_time[10];
CountType _countType;
};
- 29 -
#endif

 main.ino
#include <LiquidCrystal.h>
#include <Countimer.h>

LiquidCrystal lcd(9, 8, 7, 6, 5, 4);


Countimer timer;

uint32_t period;
uint32_t i;
uint16_t h;
uint8_t m, s;

uint32_t timing(int);
void stopwatch(int);
void refreshClock();
void onComplete();
void doStuff(uint16_t, uint8_t, uint8_t);

int coin_value;
int buzzer = A5;
int relay = 3;
int led1 = 10; // LED1 for coin insertion
int led2 = 11; // LED2 for coin inserted and value of coin detected
int led3 = 12; // LED3 when charging starts
int led4 = 13; // LED4 when charging completes

void setup()
- 30 -
{
Serial.begin(9600);
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
pinMode(led4,OUTPUT);
pinMode(buzzer,OUTPUT); // Buzzer, for when charging completes
pinMode(relay, OUTPUT); // Relay, for controlling the mobile charger

lcd.begin(16,2);
timer.setCounter(h, m, s, timer.COUNT_DOWN, onComplete);
timer.setInterval(refreshClock, 1000);

// Introduction
for(int i=400; i<=410; i=i+1)
{
lcd.setCursor(0,0);
lcd.print("Coin Detection Based");
lcd.scrollDisplayRight();
lcd.setCursor(0,1);
lcd.print("Mobile Charging System");
lcd.scrollDisplayRight();
delay(i+5);

lcd.setCursor(0,0);
lcd.print("Coin Detection Based");
lcd.scrollDisplayRight();
lcd.setCursor(0,1);
lcd.print("Mobile Charging System");
lcd.scrollDisplayRight();
delay(i+5);
}
digitalWrite(relay, HIGH);
}

- 31 -
void loop()
{
lcd.clear();
lcd.setCursor(1,0);
digitalWrite(led1, HIGH);
delay(500);
digitalWrite(led1, LOW);
delay(500);
digitalWrite(led1, HIGH);
delay(500);
digitalWrite(led1, LOW);

lcd.print("Insert a coin");
delay(5000);

digitalWrite(led1, HIGH);
delay(500);
digitalWrite(led1, LOW);
delay(500);
digitalWrite(led1, HIGH);
delay(500);
digitalWrite(led1, LOW);
delay(500);

lcd.clear();

//char buffer[] = {' ',' ',' ',' ',' ',' ',' '}; // Receive up to 7 bytes
//while(Serial.available()!=0) // Wait for characters
while (!Serial.available());
//Serial.readBytesUntil('n', buffer, 7);
//int coin_value = atoi(buffer);
//Serial.println(coin_value);

- 32 -
//{
int matlabdata=Serial.read(); // read data
int coin_value = matlabdata-48;
Serial.println(coin_value);
//coin_value = Serial.read();
//Serial.println(coin_value);

period = timing(coin_value);
Serial.print(period);

digitalWrite(led2, HIGH);
delay(500);
digitalWrite(led2, LOW);
delay(500);
digitalWrite(led2, HIGH);
delay(500);
digitalWrite(led2, LOW);
delay(500);

lcd.print("CHARGING STARTED");
delay(2000);

digitalWrite(led2, HIGH);
delay(500);
digitalWrite(led2, LOW);
delay(500);
digitalWrite(led2, HIGH);
delay(500);
digitalWrite(led2, LOW);
delay(500);

lcd.clear();

switch (coin_value)
{
- 33 -
case 1:
doStuff(0, 0, 15);
break;

case 2:
doStuff(0, 0, 30);
break;

case 5:
doStuff(0, 0, 45);
break;
}
digitalWrite(led3, LOW);

tone(buzzer, 250, 500);


//delay(200);
//tone(buzzer, 200);
//delay(200);

digitalWrite(led4, HIGH);
delay(500);
digitalWrite(led4, LOW);
delay(500);
digitalWrite(led4, HIGH);
delay(500);
digitalWrite(led4, LOW);
delay(500);
digitalWrite(led4, HIGH);
delay(500);
digitalWrite(led4, LOW);
delay(500);

//}
}

uint32_t timing(int value)


- 34 -
{
int v = value;
switch (v)
{
case 1:
i = 0.25 * 60000L; // Half minute (in ms)
break;

case 2:
i = 0.5 * 60000L;
break;

case 5:
i = 0.75 * 60000L;
break;

case 10:
i = 1 * 60000L;
break;
}
delay(1);
return i;
}

void refreshClock()
{
Serial.print("Current count time is: ");
lcd.print("time: ");

Serial.println(timer.getCurrentTime());
lcd.print(timer.getCurrentTime());
}

void onComplete()
{
- 35 -
Serial.println("Complete!!!");
lcd.print("Complete!!!");
}

void doStuff(uint16_t hours, uint8_t minutes, uint8_t seconds)


{
h = hours;
m = minutes;
s = seconds;

timer.setCounter(h, m, s, timer.COUNT_DOWN, onComplete);


timer.setInterval(refreshClock, 1000);

for( uint32_t tStart = millis(); (millis()-tStart) < period; )


{
digitalWrite(led3, HIGH);

digitalWrite(relay, LOW);
//lcd.setCursor(1,0);
//lcd.print("Time Remaining:");
lcd.setCursor(1,0);
timer.run();
if(!timer.isCounterCompleted())
{
timer.start();
}
}

digitalWrite(relay, HIGH);
}

- 36 -
FUTURE SCOPE

This project is made keeping in mind the economic and energy resources of the country. The need of the
hour is to provide access to means of communication to those who are in distress as well as providing a
source of entertainment. By extending the scope of this project, we can even charge batteries of automobiles
and electronic gadgets other than just mobile phones. Some other devices which can be charged through this
installation are camera, laptops etc. If implemented properly they can be installed at every corner of the road
and hence they will provide a suitable means to charge electric vehicles and hence can solve the problem of
air pollution. This project can further be extended to those devices which come enabled with NFC and
wireless charging, and hence can prove to be a revolution in charging history.

An IOT based server can be created which keeps a track of all the installations i.e. locations which are
equipped with this technology. Those who are in need to charge their cellphone can check the location of
this installation and have a peace of mind.
Another application is that once you have placed your mobile phone for charging, user will be provided a
link which can be checked continuously and here user can track all the information such as time remaining
for charging to accomplish, slots available for connecting more cell phones, distance from the installation,
information related to our setup, career , growth and future scope of this project. Information accumulated at
one place not only look soothing to the eyes but also present information in a very manageable way.

- 37 -
CONCLUSION

Through this project we have put our hands into one of the most common problems of this present era. By
providing these charging points we can ensure the safety of our citizens as well as ensure progress in the
growing digital population. Once this battery solution of mobile phones is addressed and solved we can also
provide solutions i.e. charging ports to automobiles which can lead to a healthy environment.

- 38 -
REFERENCES

1. S.B. Sridevi1, A.Sai Suneel2, K. Nalini3, Coin Based Mobile Charger Using Solar Tracking System,
ISSN: 2278909X Volume 2, Issue 9, September 2013.
2. Borkar , S.A.1,Dafle B.B.2, Choche R.A.3, Coin Operated Universal Mobile Charging With Solar
Tracking, ISSN:2278909X, Volume 5, Issue 3, March 2016.
3. Khashman A., Sekeroglu B. And Dimililer K., Intelligent Coin Identification System, Proceedings of
the IEEE International Symposium on Intelligent Control (ISIC06), Munich, Germany, 4-6 October
2006.
4. Saranya das. Y. M, R. Pugazhenthi, Harris Hessian Algorithm for Coin Apprehension, International
Journal of Advanced Research in Computer Engineering Technology (IJARCET) Volume 2, No 5, May
2013.
5. Usha Nandhini Sridhar, G.Swathi , Automated Mobile Phone Charger System with Coin Detection
Using Image Processing, International Journal of Advanced Research Trends in Engineering and
Technology (IJARTET) Vol. II, Special Issue VIII, February 2015 ISSN: 2394-3777 (Print), ISSN:
2394-3785 (Online)

- 39 -

You might also like