Advanced ATM Security System by Using Smart Card and IOT Technology
Advanced ATM Security System by Using Smart Card and IOT Technology
BACHELOR OF TECHNOLOGY
in
COMPUTER SCIENCE AND ENGINEERING
By
2019-2020
i
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
CERTIFICATE
This is to certify that the report entitled “Advanced ATM Security System
External Examiner
ii
ACKNOWLEDGMENT
Entrusting into Project work of “Advanced ATM Security System By Using Smart
card and IoT Technology” enabled us to express our special thanks to Dr. P.
Krishna Rao, Chairman of Pragati Engineering College, (Autonomous)
Surampalem.
We extremely thankful to our honorable Principal Dr. S. Sambhu Prasad, who has
shown keen interest in us and encouraged us by providing all the facilities to
complete our project successfully.
We owe our gratitude to our beloved Head of the Department of CSE, Dr.
M.Radhika Mani, for assisting us in completing our project work.
We express our sincere thanks to our guide Mr. A. Janarthan Rao who has been a
source of inspiration for us throughout our project and for his valuable advices in
making our project a success.
iii
ABSTRACT
This project is designed to gain access to an area or control a device by using a valid
smart card only. The security of any organization is the top most priority for the
concerned authorities. For this reason only, the authorized person with a valid smart
card is allowed to operate the device/ to access a secure area. Earlier, human
supervision was required to monitor all these parameters, but with this proposed
system no supervision is required as only authorized persons are provided with valid
A smart card reader is provided to read data from the card assigned to the
authorized personnel. The smart card reader is interfaced to an ARM-7. Whenever the
data read by the smart card matches with the data on the microcontroller then LCD
would display that the card is authorized and a relay is used simultaneously to switch
in the smart card reader, it displays that the card is not authorized and the load (i.e.
lamp) remains OFF indicating that the user is not authorized to access the particular
area/device.
This project can be enhanced further by integrating GSM modem such that
any attempt of unauthorized access is made, then an alert SMS is sent to the
iv
TABLE OF CONTENTS
ACKNOWLEDGMENT iii
ABSTRACT iv
LIST OF TABLES ix
LIST OF ABBREIVATIONS x
Chapter 1 INTRODUCTION 1
1.1 Introduction 1
1.3 Characteristics 3
1.7 Applications 6
Micro Controller 8
v
Chapter 2 OVERVIEW OF THE PROJECT 9
2.5 Description 14
3.1.2 Convert AC to DC 16
3.3.2 MAX232 19
communication) 19
Identification) 21
3.5.2 Readers 23
vi
3.5.3 Antennas and Radio 24
Micro Controller 26
3.8 Motor 35
4.2 Proteus 44
4.2.1 Introduction 44
Chapter 6 CONCLUSION 49
BIBLIOGRAPHY 50
APPENDIX 51
vii
LIST OF FIGURES
viii
LIST OF TABLES
ix
LIST OF ABBREVIATIONS
Abbreviation Description
ATM Automated Teller Machine
ALU Arithmetic Logical Unit
SCI Serial Communication Interface
USB Universal Serial Bus
WSN Wireless Sensor Network
GSM Global System for Mobile
MEMS Micro Electrical Mechanical Systems
RPS Regulated Power Supply
LCD Liquid Crystal Display
RFID Radio Frequency Identification
ARM Arithmetic RISC Machine
RISC Reduced Instruction Set Computer
SOA Service Oriented Architecture
TDMA Time Division Multiple Access
FDMA Frequency Division Multiple Access
AC Alternate Current
DC Direct Current
LED Light Emitting Diode
GPIO General Purpose Input Output
MAC Medium Access Control
JTAG Joint Test Action Group
USART Universal Synchronous/Asynchronous
Receiver/Transmitter
x
Advanced ATM Security System By Using Smart card and IOT Technology
CHAPTER 1
INTRODUCTION
1.1 INTRODUCTION:
1.3 CHARACTERISTICS:
The software written for embedded systems is often called firmware, and
is usually stored in read-only memory or Flash memory chips rather than a disk drive.
It often runs with limited computer hardware resources: small or no keyboard, screen,
and little memory.
Anyone who says that the Internet has fundamentally changed society may be
right, but at the same time, the greatest transformation actually still lies ahead of us.
Several new technologies are now converging in a way that means the Internet is on
the brink of a substantial expansion as objects large and small get connected and
assume their own web identity.
Following on from the Internet of computers, when our servers and personal
computers were connected to a global network, and the Internet of mobile telephones,
when it was the turn of telephones and other mobile units, the next phase of
development is the Internet of things, when more or less anything will be connected
and managed in the virtual world. This revolution will be the Net’s largest
enlargement ever and will have sweeping effects on every industry — and all of our
everyday lives.
1. Application Layer
2. Gateway and the network layer
3. Management Service layer
4. Sensor layer
1.7 APPLICATIONS:
There are several application domains which will be impacted by the emerging
Internet of Things. The applications can be classified based on the type of network
availability, coverage, scale, heterogeneity, repeatability, user involvement and
impact.
(2) Enterprise
(3) Utilities
(4) Mobile.
CPU Serial
RAM ROM COM
General I/O Port Timer Port
MICROCONT
ROLLERS
(MCU)-
Purpose
2. Microprocessor need many opcodes for moving data from the external
memory to the CPU, microcontroller may require just one or two, also microprocessor
may have one or two types of bit handling instructions whereas microcontrollers have
many.
CHAPTER 2
OVERVIEW OF THE PROJECT
The main objective of this project is to operate solar system by using IOT. We
can observe the parameters are temperature, humidity, Environmental conditions &
voltage by providing security of IOT.
These units send their data wireless to a central station, which collects the
data, stores and displays them into a database. The facility of adding a few
more sensors and a few more stations has been provided.
Power supply.
ARM-7
LCD
Smartcard.
Voltage Converter (MAX232)
Buzzer
GSM
MOTOR
KEYPAD
2.3.3 Software Requirements are:
keil
Proteous
Code develops through Embedded C
2.5 DESCRIPTION:
This project is implemented for how we utilize the new technologies in our
world are use full for everyone ,so we have to implement the internet based data
monitoring system IOT technology is used for monitoring this parameters from
anywhere.
Here we are implement the IOT based ATM security system using smart card
technology,
Any ATM system requires neigh security, to remember this point we need to
design this project using SMART CARD with IOT technology. Initially we have to
check the conditions (vibrator and reader) if vibrating sensor is activated immediately
alert message send to the particular number and also system continuously check the
reader data, if any authentication is occurred (security alarm breached) particular
person image gets captured and it sends the image to the person’s mail ID and an alert
SMS is sent to the person’s phone number
CHAPTER 3
HARDWARE IMPLEMENTATION
Hardware components are
Power supply.
GSM
RFID
SMART CARD
LCD
ARM-7(lpc2148)
Voltage Converter (MAX232)
MOTOR
KEYPAD
230V AC power is converted into 12V AC (12V RMS value where in the peak
value is around 17V), but the required power is 5V DC; for this purpose, 17V AC
power must be primarily converted into DC power then it can be stepped down to the
5V DC. But first and foremost, We must know how to convert AC to DC? AC power
can be converted into DC using one of the power electronic converters called as
Rectifier. There are different types of rectifiers, such as half-wave rectifier, full-wave
rectifier, full-wave rectifier and Bridge rectifier. Due to the advantages of the bridge
rectifier over the half and full wave rectifier, the bridge rectifier is frequently used for
converting AC to DC
Bridge rectifier consists of four diodes which are connected in the form a
bridge .We know that the diode is an uncontrolled rectifier which will conduct only
forward bias and will not conduct during the reverse bias. If the diode anode voltage
is greater than the cathode voltage then the diode is said to be in forward bias. During
positive half cycle, diodes D2 and D4 will conduct and during negative half cycle
diodes D1 and D3 will conduct. Thus, AC is converted into DC ; here the obtained is
not a pure DC as it consist of pulses .Hence ,it is called as pulsating DC power. But
voltage drop across the diodes is (2*0.7V) 1.4V; Therefore, the peak voltage at the
voltage at the output of this rectifier circuit is 15V (17-1.4) approx.
LCD (liquid crystal display) is the technology used for displays in notebook
and other smaller computers. Like light-emitting diode (LED) and gas-plasma
technologies, LCDs allow displays to be much thinner than cathode ray tube ( CRT)
technology. LCDs consume much less power than LED and gas-display displays
because they work on the principle of blocking light rather than emitting it.
Today, most of the latest microcontrollers are integrated with at least one USART
(Universal Synchronous Asynchronous Receiver Transmitter) peripheral. A well set
module is very useful not only to establish a communication medium (receive or
transmit data) between microcontroller and PC but also to program the device via
preloaded boot-loader. Here is how to make proper level converter using MAX232.
Before that, it is better to have a simple idea about RS232 & TTL levels.
In RS232 protocol, +12V indicates the Space state or Zero and -12V indicates
the Mark state or 1. In TTL, +5V indicates the Mark state and 0 indicates Space state.
Most importantly, TTL level is not accepting negative voltage levels. So for the
RS232 to TTL interface translation is not only a task with 12V to 5V level shifting,
and it includes a level inversion too. To do that, MAX232 is more often used in
microcontroller applications.
3.3.2 MAX232 :-
system. This has also meant that data communication was built into the system using
the 3rd Generation Partnership Project
A command string should start with "AT" or "at", except for the commands
"A/" and "+++". At or aT are invalid.
Several commands can be given in one command string.
The commands can be given in upper or lower case.
A command string should contain less than 40 characters.
When an error is made during the typing of the command, it can be corrected
using the backspace key.
Commands and command strings must be terminated with an <ENTER>,
except +++ and A/
A telephone number can exist of following characters: 1 2 3 4 5 6 7 8 9 * =, ; #
+ > . All other characters are ignored (space, underscore). They help
formatting the dial string.
The tag is the basic building block of RFID. Each tag consists of an antenna and a
small silicon chip that contains a radio receiver, a radio modulator for sending a
response back to the reader, control logic, some amount of memory, and a power
system. The power system can be completely powered by the incoming RF signal, in
which case the tag is known as a passive tag. Alternatively, the tag’s power system
can have a battery, in which case the tag is known as an active tag.
The primary advantages of active tags are their reading range and reliability.
With the proper antenna on the reader and the tag, a 915MHz tag can be read from a
distance of 100 feet or more. The tags also tend to be more reliable because they do
not need a continuous radio signal to power their electronics.
Passive tags, on the other hand, can be much smaller and cheaper than active
ones because they don’t have batteries. Another advantage is their longer shelf life:
Whereas an active tag’s batteries may last only a few years, a passive tag could in
principle be read many decades after the chip was manufactured
Between the active and the passive tags are the semi-passive tags. These tags
have a battery, like active tags, but still use the reader’s power to transmit a message
back to the RFID reader using a technique known as backscatter. These tags thus have
the read reliability of an active tag but the read range of a passive tag. They also have
a longer shelf life than a tag that is fully active.
Electronic Product Code (EPC) tags are a special kind of tag that follows the EPC
standard developed by the MIT Auto-ID Center and is now managed by the trade
organization EPC global. Sanjay Sharma, cofounder of the Auto-ID Center.
3.5.2 READERS
The RFID reader sends a pulse of radio energy to the tag and listens for the
tag’s response. The tag detects this energy and sends back a response that contains the
tag’s serial number and possibly other information as well.
Historically, RFID readers were designed to read only a particular kind of tag,
but so-called multimode readers that can read many different kinds of tags are
becoming increasingly popular.
RFID readers are usually on, continually transmitting radio energy and
awaiting any tags that enter their field of operation. However, for some applications,
this is unnecessary and could be undesirable in battery-powered devices that need to
conserve energy. Thus, it is possible to configure an RFID reader so that it sends the
radio pulse only in response to an external event.
Most RFID systems use the unlicensed spectrum, which is a specific part of the
spectrum set aside for use without a radio license. Popular bands are the low-
frequency (LF) band at 125–134.2KHz, the high-frequency band at 13.56MHz, the
ultrahigh-frequency (UHF) band at 915MHz, and the industrial, scientific, and
medical (ISM) band at 2.4GHz.
The names of the LF, HF, and UHF bands reflect the history of radio’s
development: Radio systems first transmitted at the lower frequencies and moved to
the higher frequencies only as technology advanced. For this reason, lower frequency
radio gear was traditionally cheaper than equipment that operated at higher
frequencies.
When analyzing the energy that is radiated from an antenna, electrical engineers
divide the field into two parts: the near field, which is the part of radiation that is
within a small number of wavelengths of the antenna, and the far field, which is the
energy that is radiated beyond the near field. Because the wavelength of LF and HF
devices tends to be much larger than the ranges at which RFID systems typically
operate, these systems operate in the near field, while UFH and ISM systems operate
in the far field.
Most RFID tags transmit a number and nothing more. So what does a typical
reader do with a typical 96-bit number like 79,228,162,514,264,337,593,
543,950,335. In most cases, the reader sends it to a computer.
What the computer does with the RFID code depends on the application. With
an access-control system, the computer might look to see if the RFID number is
present on a list of numbers that’s allowed access to a particular door or location. If
the number is present, the computer might energize a solenoid that would unlock the
door. In the case of the Mobil Speed pass system, the tag’s serial number and its
response to the random challenge that was generated by the reader are sent over
Mobil’s payment network. If the challenge response matches the token, Mobil’s
computers approve the user of the customer’s credit-card number to complete the
transaction.
3.6 SMAETCARDS:
A smart card is a physical card that has an embedded integrated chip that acts as
a security token. Smart cards are typically the same size as a driver's license or credit
card and can be made out of metal or plastic. They connect to a reader either by direct
physical contact (also known as chip and dip) or through a short-range wireless
connectivity standard such as radio-frequency identification (RFID) or near-field
communication (NFC).
Smart cards are used for a variety of applications, though most commonly are used for
credit cards and other payment cards. Distribution of smart cards in recent years has
been driven by the payment card industry's move to support smart cards for the EMV
payment card standard. Smart cards capable of short-range wireless connectivity can
also be used for contactless payment systems; they can also be used as tokens for
multifactor authentication.
Pin3-RTXC1 3
It is an I/p to the RTC-oscillator circuit
Pin5-RTXC2
This is an output pin from the RTC oscillator circuit
Pin7-VDDA
This pin is an analog voltage power supply (3.3V), and this voltage is very
useful for the on-chip analog to digital converters and digital to analog
converters.
Pin8- P1.18/TRACEPKT2
P1.18 is a GPIO digital pin.
TRACEPKT2 is a trace packet, bit-2, standard input/output port by the inner
pull-up.
Pin9- P0.25/AOUT/AD0.4
P0.25 is a GPIO digital pin I
Pin11- D-
This pin is a USB bidirectional D- line
Pin12-P1.17/TRACEPKT1
P1.17 is a GPIO digital pin
TRACEPKT1 is a trace packet, bit-1, standard input/output port by the inner
pull-up.
Pin24- P1.26/RTCK
P1.26 is a GPIO digital pin
RTCK is a returned test CLK o/p, an additional signal added to the JTAG-port.
When the frequency of processor changes then it helps debugger
synchronization.
Pin26- P0.3/ SDA0/ MAT0.0/EINT1
P0.3 is a GPIO digital pin
SDA0 is an I2C0 data I/O and open drain o/p for I2C bus observance.
MAT0.0 is matched o/p for timer-0, channel-0.
EINT1 is an external interrupt 1-i/p.
Pin27-P0.4/ CAP0.1/ SCK0/AD0.6
P0.4 is a GPIO digital pin I/O
SCK0 is a serial CLK for SPI0 and SPI CLK o/p from master/ i/p to slave.
CAP0.1 is a capture i/p for timer-0, channel-0.
IAD0.6 denotes ADC-0, input-6
Pin28-P1.25/EXTIN0
P1.25 is a GPIO digital pin I/O
EXTIN0 is an external trigger i/p, and standard input/output with inner pull-up
Pin29- P0.5/MAT0.1/MISO0/AD0.7
P0.5 is a GPIO digital pin I/O
MISO0 is a master in slave out for SPI0, data i/p to SPI-master/data o/p from
SPI slave.
MAT0.1 is a match o/p for timer-0, channel-1.
AD0.7 denotes ADC-0, input-7.
Pin30-P0.6/MOSI0/CAP0.2/AD1.0
P0.6 is a GPIO digital pin I/O
MOSI0 is a master out slave in for SPI0, and data o/p from SPI master/ data i/p
to SPI slave.
CAP0.2 is a capture i/p for Timer-0, channel-2.
Pin31-P0.7/ PWM2/ SSEL0/EINT2
P0.7 is a GPIO digital pin I/O
SSEL0 is a slave select for SPI0 and chooses the SPI-interface as a slave.
PWM2 is a pulse width modulator output-2.
EINT2 is an external interrupt 2-input.
Pin32-P1.24/TRACECLK
P1.24 is a GPIO digital pin I/O.
TRACECLK is a trace CLK and standard input/output port with inner pull-up
Pin33-P0.8/TXD1/PWM4/AD1.1
P0.8 is a GPIO digital pin I/O
TXD1 is a transmitter o/p for UART1.
PWM4 is a pulse width modulator o/p-4.
AD1.1 denotes ADC-1, input-1, and it is obtainable only in LPC2144/46/48.
Pin34- P0.9/PWM6/RXD1/EINT3
P0.9 is a GPIO digital pin I/O
RXD1 is a receiver i/p for UART1.
PWM6 is a pulse width modulator o/p-6.
EINT3 is an external interrupt 3-input
Pin35-P0.10/RTS1/CAP1.0/AD1.2
SCL1 — I2C1 CLK I/O, and open drain o/p for the I2C-bus observance
Pin38-P0.12/ MAT1.0/AD1.3/ DSR1
Pin49: VBAT
RTC power supply: This pin gives the supply to the RTC.
Pin52: P1.30/TMS
Pin56: P1.29/TCK
Pin58: P0.23/VBUS
P0.23 is a GPIO digital pin I/O
VBUS specifies the existence of USB-bus power
Pin59: VSSA
VSSA is an analog ground, and this must be the similar voltage like VSS,
although it should be separated to reduce error and noise
Pin60: P1.28/TDI 60
P1.28 is a GPIO digital pin I/O
TDI pin is a test data is used for interfacing JTAG
Pin61: XTAL2
XTAL2 is an o/p from the oscillator amplifier
Pin62: XTAL1
XTAL1 is an i/p to the internal CLK generator as well as oscillator circuits
This pin should be nominally equal or less than to the voltage VDD although it
should be separated for reducing error as well as noise.
Pin64: P1.27/TDO 64
It often helps to explain how a brushed DC motor works first, as they were
used for some time before brushless DC motors were available. A brushed DC motor
has permanent magnets on the outside of its structure, with a spinning armature on the
inside. The permanent magnets, which are stationary on the outside, are called the
stator. The armature, which rotates and contains an electromagnet, is called the rotor
CHAPTER 4
SOFTWARE COMPONENTS
Flash Magic:
Flash Magic is a tool which is used to program hex code in EEPROM of micro-
controller. It is a freeware tool. It only supports the micro-controller of Philips and
NXP. It can burn a hex code into that controller which supports ISP (in system
programming) feature. Flash magic supports several chips like ARM Cortex M0,
M3, M4, ARM7 and 8051.
2. Supply power into board; in this case, we can see red LED1 is in status ON.
3. Set jumper BR4 (INT1) in ON state.
4. Run Program Flash Magic, it will display result as shown in Figure 1.1
5. Start setting the initial values into program as desired, so we configure values into
program as follows;
4.1 Select COM port corresponding with (in this example, it is
COM1)
4.2 Set the baud rate to 9600
4.3 Set Device to be LPC2148
4.4 Set Interface to be None ISP
4.5 Set Crystal Oscillator with MHz corresponding with the value
internal Board. In this case, it is 12.000MHz, so we must set to
be 12.
4.6 Press ISP LOAD Switch (S1) and RESET Switch (S2) on
Board “ARM7 LPC2148 Development Board” to reset MCU to run
in Boot Loader following the processes;
Press ISP LOAD Switch (S1) and hold
Press RESET Switch (S2) while ISP LOAD Switch (S1) is
being held.
Remove RESET Switch (S2) but ISP LOAD Switch (S1) is
being held.
Lastly, remove ISP LOAD Switch (S1).
6. Select format of erasing data to be “Erase all Flash + Code Rd Prot”.
7. Set Option to be “Verify after programming”.
8. Click “Browse” to select HEX File for downloading.
9. Click “Start”, Program Flash Magic will start downloading data into MCU
instantly. In this case, we can see the status operation at Status Bar and we must
wait for the operation until it is completed.
10. When the operation of program is complete, press RESET Switch on Board and
MCU will start running follow the downloaded program instantly.
11. Run Program Flash Magic, it will display result as shown in Figure 1.1
Start setting the initial values into program as desired, so we configure values into
program as follow sections.
Step-1 Communication:
b) Select your com port and if you are using USB to serial converter make sure that
you will select proper com port other wise you can not communicate.
c) Now select baud rate ideally it should be 9600 (recommended). Avoid higher than
9600 for proper communication.
d) Now select your interface if you are using DB-9 then it will be None (ISP).
e) Set Crystal Oscillator with MHz corresponding with the value internal Board.
In this case, it is 12.000MHz, so we must set to be 12.
Press ISP LOAD Switch (S1) and RESET Switch (S2) on Board “ARM7
LPC2148 Development Board” to reset MCU to run in Boot Loader following
the processes;
Press ISP LOAD Switch (S1) and hold
Press RESET Switch (S2) while ISP LOAD Switch (S1) is being held.
Remove RESET Switch (S2) but ISP LOAD Switch (S1) is being held.
Lastly, remove ISP LOAD Switch (S1).
Step-2 Erase:
Select format of erasing data to be “Erase all Flash + Code Rd Prot”
Now here tick mark the Erase all Flash option. This is the most crucial thing because
wrong selection in this step can be resulting into lost of boot loader in your chip.
Nothing to worry if you lost your boot loader because you can again load it but to
load boot loader you must program you chip through universal programmer or any
other programmer which is not depend upon boot loader for loading hex code. After
loading boot loader you can again able to program your chip using flash magic.
This is very simple and you need to set up a path of your Hex file which is to be
loaded on chip.
Step-4 Options:
In this always keep Verify after programming option enable by tick mark. You can
use another features as well according to your need.
Step-5 Start:
Click “Start”, Program Flash Magic will start downloading data into MCU instantly.
In this case, we can see the status operation at Status Bar and we must wait for the
operation until it is completed. When the operation of program is complete, press
RESET Switch (S2) on Board and MCU will start running follow the downloaded
program instantly.
4.2 PROTEUS
4.2.1 INTRODUCTION:
Generally we are listening the words PCB’s, PCB layout, PCB designing, etc.
But what is PCB? Why we are using this PCB? We want to know about all these
things as a electronic engineer. PCB means Printed Circuit Board. This is a circuit
board with printed copper layout connections. These PCB’s are two types. One is
dotted PCB and another one is layout PCB. The two examples are shown in below.
Fig 4.1: The Main Difference Between The Dotted PCB And Layout PCB
What is the main difference between the dotted PCB and layout
PCB?
In dotted PCB board only dots are available. According to our requirement we
can place or insert the components in those holes and attach the components with
wires and soldering lid. In this dotted PCB we can make the circuit as out wish but it
is very hard to design. There are so many difficulties are there. Those are connecting
the proper pins, avoiding shot connections and etc. Coming to the layout PCB this is
simple to design. First we select the our circuit and by using different PCB designing
software’s, design the layout of the circuit and by itching process preparing the copper
layout of our circuit and solder the components in the correct places. It is simple to
design, take less time to design, no shortages, looking nice and perfect
If any modifications want to do to the component place the mouse point and click on
right button then option window will open. That is shown in below figure.
After completion of designing save with some mane and debug it. This is virtual
simulation means without making circuit we can see the result in virtually through
this software and we can design the PCB layout to our required circuit with this
software.
CHAPTER 5
RESULT AND ANALYSIS
CHAPTER 6
CONCLUSION AND FUTURE SCOPE
CONCLUSION:
Future Scope:
BIBLIOGRAPHY
REFERENCES
APPENDIX
SOURCE CODE :
#include "LPC214x.h"
#include <stdio.h>
#include <string.h>
#include "lcd.c"
#include "uart.h"
#include "uart0.c"
#include"uart1.c"
#define r1 0x00010000
#define r2 0x00020000
#define r3 0x00040000
#define r4 0x00080000
#define c1 0x00100000
#define c2 0x00200000
#define c3 0x00400000
#define mot 0x00010000
#define mot1 0x00020000
#define b 0x00040000
void send_sms(void);
void keypad(void);
void gate();
int pk;
void delay1(void)
{
int i;
for(i=0;i<400000;i++);
}
unsigned int data,key,k=0,i,ch,sms[10],ks=0,kss=0,psw[5],ii;
unsigned char rfid[12],usr,ussr,id,lvl=3;
unsigned int d1=0,d2=0;
void longdelay(unsigned int v)
{
int i,j;
for(i=0;i<=v;i++)
for(j=0;j<=10000;j++);
}
int main()
{
IODIR0 |=0x000F0000;
IODIR0 &=0xFF0FFFFF;
IODIR1 |=0x000F0000;
init_serial0();
init_serial1();
lcd_init();
longdelay(100);
IOSET1=mot;
IOSET1=mot1;
IOSET1=b;
while(1)
{
lcd_write_control(0x01);
lcd_print(" WELCOME");
lcd_write_control(0xc0);
lcd_print("ENTER ANY KEY");
keypad();
lcd_write_control(0x01);
lcd_print(" WELCOME");
lcd_write_control(0xc0);
lcd_print("SHOW YOUR CARD");
longdelay(1000);
sprintf(uart0_buf,"SHOW CARD\r\n");
print_uart0();
if((U1LSR & 0x20))
{
for(ii=0;ii<11;ii++)
{
rfid[ii]=getchar1();
putchar0(rfid[ii]);
}
ii=getchar1();
rfid[ii]='\0';
lcd_write_control(0xce);
lcd_write_ascii(rfid[10]);
longdelay(1000);
}
putchar0(rfid[10]);
if(rfid[10]=='A' || rfid[10]=='9' )
{
sprintf(uart0_buf,"card ok enter otp\r\n");
print_uart0();
lcd_write_control(0x01);
lcd_print("CARD OK..");
longdelay(1000);
lcd_write_control(0x01);
lcd_print("Pls enter OTP");
sprintf(uart1_buf,"AT+CMGF=1\r\n");
print_uart1();
longdelay(400);
longdelay(1000);
sprintf(uart1_buf,"AT+CMGS=");
print_uart1();
longdelay(400);
putchar1('"'); // Transffer data to PC through Serial
sprintf(uart1_buf,"9704056156");
print_uart1();
longdelay(400);
putchar1('"'); // Transffer data to PC through Serial
putchar1(13);
longdelay(200);
sprintf(uart1_buf,"Your OTP:");
d2=d1;
print_uart1();
putchar1(d1/1000+48);
putchar1((d1/100)%10+48);
putchar1((d1/10)%10+48);
putchar1(d1%10+48);
putchar0(d1/1000+48);
putchar0((d1/100)%10+48);
putchar0((d1/10)%10+48);
putchar0(d1%10+48);
longdelay(500);
putchar1(0x1a);
longdelay(300);
longdelay(1000);
for(i=0;i<=3;i++)
{
k=0;
keypad();
lcd_write_ascii(key);
putchar0(key);
psw[i]=key;
IOCLR1=b;
longdelay(20);
IOSET1=b;
}
if(psw[0] == (d2/1000+48) && psw[1] == ((d2/100)%10+48) && psw[2] ==
((d2/10)%10+48) && psw[3] == ((d2/1)%10+48))
{
printf(uart0_buf,"OTP OK\r\n"); // Transffer data to PC through Serial
print_uart0();
lcd_write_control(0x01);
lcd_print("OTP ok");
IOSET1=mot;
IOCLR1=mot1;
longdelay(2000);
IOSET1=mot;
IOSET1=mot1;
}
else
{
putchar0('*');
sprintf(uart0_buf,"WRONG OTP\r\n");
print_uart0();
IOCLR1=b;
lcd_write_control(0x01);
lcd_print("UNAUTHORIZED ACCESS");
longdelay(2000);
IOSET1=b;
}
}
else
{
putchar0('*');
IOCLR1=b;
sprintf(uart0_buf,"WRONG CARD...\r\n");
print_uart0();
lcd_write_control(0x01);
lcd_print("UNAUTHORIZED ACCESS");
longdelay(2000);
IOSET1=b;
}
}
}
void keypad()
{
do
{
d1++;
if(d1>9999)
d1=1000;
IOSET0=0x000F0000;
IOCLR0=0x00010000;
if((IOPIN0 & c1) !=c1)
{
while((IOPIN0 & c1) !=c1);
// lcd_write_control(0xc0);
// lcd_write_ascii('1');
k=1;
key='1';
}
if((IOPIN0 & c2) !=c2)
{
while((IOPIN0 & c2) !=c2);
// lcd_write_control(0xc0);
// lcd_write_ascii('2');
k=1;
key='2';
}
if((IOPIN0 & c3) !=c3)
{
while((IOPIN0 & c3) !=c3);
// lcd_write_control(0xc0);
// lcd_write_ascii('3');
k=1;
key='3';
}
IOSET0=0x00010000;
IOCLR0=0x00020000;
if((IOPIN0 & c1) !=c1)
{
while((IOPIN0 & c1) !=c1);
// lcd_write_control(0xc0);
// lcd_write_ascii('4');
k=1;
key='4';
}
// lcd_write_ascii('0');
key='0';
k=1;
}