21-05-2012, 05:26 AM
My name is shahbaz and i am doing my final year project in MIT,manipal and as my final project I have an rfid module that scans rfid tags and displays access granted on lcd if the tag is present in memory and access denied if not, My professor wants me to include a recorded message using apr9600 which says welcome on the scanning of correct id and, sorry wrong id message on scanning an unidentified tag, he existing c code and how do i interface the apr9600 with the existing module ?
Here is the code in c
#include<reg51.h>
#include<conio.h>
unsigned int data_out,command=0x80,temp;
sfr lcd_data_pin=0x80; //P0 port
sbit rs=P2^0; //Register select
sbit rw=P2^1; //Read/Write
sbit en=P2^2; //Enable pin
unsigned char card_id[12];
unsigned char card_mem[2][12]={'4','2','0','0','6','C','1','E','9','5','A','5','4','2','0','0','A','7','4','9','8','8','2','4'};
void delay(unsigned int count) //Function to provide delay
{
int i,j;
for(i=0;i<count;i++)
for(j=0;j<1275;j++);
}
void lcd_command(unsigned char comm) //Lcd command funtion
{
lcd_data_pin=comm;
en=1;
rs=0;
rw=0;
delay(1);
en=0;
}
void lcd_data(unsigned char disp) //Lcd data function
{
lcd_data_pin=disp;
en=1;
rs=1;
rw=0;
delay(1);
en=0;
}
lcd_string(unsigned char *disp) //Function to send string
{
int x;
for(x=0;disp[x]!=0;x++)
{
lcd_data(disp[x]);
}
}
void lcd_ini() //Function to initialize the LCD
{
lcd_command(0x38);
delay(5);
lcd_command(0x0F);
delay(5);
lcd_command(0x80);
delay(5);
}
void recieve() //Function to recieve data serialy from RS232
{
unsigned char k;
for(k=0;k<12;k++)
{
while(RI==0);
card_id[k]=SBUF;
RI=0;
}
}
void main()
{
int l;
int actiavted=0;
int count=0;
TMOD=0x20; //Enable Timer 1
TH1=0XFD;
SCON=0x50;
TR1=1; // Triggering Timer 1
lcd_ini();
while(1)
{
lcd_ini();
lcd_command(0x81); //Place cursor to second position of first line
lcd_string("UNIQUE CARD ID:");
delay(200);
recieve();
lcd_command(0xC1); //Place cursor to second position of second line
for(l=0;l<12;l++)
{
lcd_data(card_id[l]);
}
delay(200);
for(int ab=0;ab<2;ab++)
{
count=0;
for(int cd=0;cd<12;cd++)
{
if(card_id[cd]=card_mem[cd])
{
count++;
}
}
if(count==12)
{
activated=1;
}
else
{
activated=0;
}
}
lcd_ini();
if(activated==1)
{
lcd_string("Access granted");
delay(500);
}
else if(activated==0)
{
lcd_string("Access denied")
}
}
getch();
}