RFID based home security system

This project RFID based Home/Office security system is developed to build a security system for a home/office to prevent the other persons to enter into the important room/chamber by controlling radio frequency identification by checking a suitable RFID card The RFID tag gives the unique id whenever it reads the card information. This id information is send to the micro controller to check the correct card to take a security action. If the card id matches with the original information, it allows entering into the room and acknowledges the authorized, if not gives the unauthorized message on LCD as an indication of wrong person tried to enter into the room there are certain places where accuracy is important mainly in banking, health care and government sectors. This application will provide RFID tag based system which uses microcontroller atmega32 here. 

Proteus Design

 

CODE

/*
 * rfid_security.c
 *
 * Created: 6/12/2014 9:02:10 PM
 *  Author: rohit
 */ 

#include <avr/io.h>
#include <string.h>
#include <util/delay.h>
#define lcdport PORTA
#define signal PORTB
#define en PB2
#define rw PB1
#define rs PB0
#define m1 PB3
#define m2 PB4
void lcdcmd(unsigned char cmd);
void lcdint();
void lcddata(unsigned char data);
void lcd_print(char * str);
void usart_init();
void usart_receive();
void usart_send(unsigned char);
void entry();
unsigned char value;
unsigned char store[15];
unsigned char card1[]="123456789000";
unsigned char card2[]="6F008805DB39";

void usart_init()
{
UCSRB=(1<<TXEN)|(1<<RXEN); // transmit enable
UCSRC=(1<<UMSEL)|(1<<UCSZ1)|(1<<UCSZ1); //synchronous mode,8-bit character size
UBRRL=0x33; //9600 baud rate
}
int main(void)
{
usart_init();
DDRA=0xff;//output port
DDRB=0b00011111;
lcdint();
while(1)
    {
lcdcmd(0x01);
lcdcmd(0x02);
lcdcmd(0x80);
lcd_print("unique code");
_delay_ms(200);
lcdcmd(0xc0);
usart_receive();
entry();
    }
}
void entry()
{
if ((strcmp(store,card1)==0)||(strcmp(store,card2)==0))
{
lcdcmd(0x01);
lcdcmd(0x02);
lcd_print("id matched");
_delay_ms(2000);
   lcdcmd(0x01);
lcd_print("opening door");
signal|=(1<<m1);
_delay_ms(10000);
signal&=~((1<<m1)|(1<<m2)); // stop motor for a while
_delay_ms(5000);
lcdcmd(0x01);
lcd_print("closing door");
signal|=(1<<m2);
_delay_ms(10000);
signal&=~(1<<m2);

else
{
lcdcmd(0x01);
lcdcmd(0x02);
lcd_print("wrong entry");
lcdcmd(0xc0);
lcd_print("try again");
_delay_ms(5000);
}
}
void lcdint()
{
lcdcmd(0x38);
_delay_ms(1);
lcdcmd(0x01);
_delay_ms(1);
lcdcmd(0x0E);
_delay_ms(1);
}
void lcdcmd(unsigned char x)
{
lcdport=x;
signal|=(0<<rs)|(0<<rw)|(1<<en);
_delay_ms(1);
signal&=(0<<rs)|(0<<rw)|(0<<en);
_delay_ms(50);
}
void lcddata(unsigned char data)
{
lcdport= data;
signal|=(1<<rs)|(0<<rw)|(1<<en);
_delay_ms(1);
signal&=(1<<rs)|(0<<rw)|(0<<en);
_delay_ms(50);
}
void lcd_print(char * str)
{
unsigned char i = 0;
while(str[i]!=0)
{
lcddata(str[i]);
i++;
}
}
void usart_receive()
{
int k;
for(k=0;k<12;k++)
{
while(!(UCSRA & (1<<RXC)));
value=UDR;
store[k]=value;
usart_send(value);
 }
}
void usart_send(unsigned char ch)
{
while(!(UCSRA & (1<<UDRE))); //wait until UDR is empty
UDR=ch;
}

Category: 

tags: 

Share

Who's new

  • ravirajpatil871...
  • shubhambajoria
  • yassir
  • demiholyman890954
  • scottgillum51169040

Get Notified

 

Share

We are Social

Syndicate

Subscribe to Syndicate