Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

rfid c code on 89c51 problem plz help.

Status
Not open for further replies.

aqibpervaiz

Newbie level 1
Newbie level 1
Joined
Dec 15, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
18
hi i m making rfid base security system in which when u bring card near relay which operate and lock will be open.problem is it does not goes on the true statement it always goes on else statement what ever card i put near to it. i m share u my code plz help me.thanks in advance.


#include<reg51.h>
#include<string.h>
sbit relay=P2^0;
sbit led=P2^1;
sbit pled=P2^2;
unsigned char k=0;
char temp=1;
void delay(unsigned int itime);
void get_code();
unsigned char check();
unsigned char aqib[13]={'¿','Y','Ù','ö','Ö','‘','‘','›','‘','y','w','y','ù'};
unsigned char reid[13];
void main (){
//aqib[0]="¿"
//aqib[1]="Y"
//aqib[2]="Ù"
//aqib[3]="ö"
//aqib[4]="Ö"
//aqib[5]="‘"
//aqib[6]="‘"
//aqib[7]="›"
//aqib[8]="‘"
//aqib[9]= "y"
//aqib[10]= "w"
//aqib[11]= "y"
//aqib[12]= "ù"
//aqib[0]=10111111;
//aqib[1]=01011001;
//aqib[2]=11011001;
//aqib[3]=11110110;
//aqib[4]=11010110;
//aqib[5]=10010001;
//aqib[6]=10010001;
//aqib[7]=10011011;
//aqib[8]=10010001;
//aqib[9]=01111001;
//aqib[10]=01110111;
//aqib[11]=01111001;
//aqib[12]=11111001;
relay=0;
led =0;
pled=0;
SCON=0x50;
TMOD=0x20;
TH1=-3;
TR1=1;

while (1){

pled=1;

get_code();
//temp = strcmp(aqib,reid);
temp=check;
if (temp==13) {
relay=1;
delay(500);
relay=0;
}
else
{ unsigned char i;
for (i=0;i<10;i++){
led=1;
delay(100);
led=0;
}

}


}
}









void get_code(){

for (k=0;k<13;k++)
{
while(RI==0);
reid[k]=(char)SBUF;
RI=0;}
}
unsigned char check(){
//strcmp(reid,aqib)
unsigned char temp=0,i=0;
for (i=0;i<12;i++){
if ((reid)=(aqib)){
temp=temp+1;
}
}
return temp;
}



void delay(unsigned int itime)
{
unsigned int i,j;
for (i=0;i<itime;i++)
for (j=0;j<111;j++);
}
 

I think you need to do a little change in the following
Code:
void get_code(){

for (k=0;k<12;k++)  // Use '12' instead of '13'
{
//while(RI==0);
reid[k]=(char)SBUF;	
//RI=0;}
}

- - - Updated - - -

I mean to say the parameter for doing the true statement is getting the ID card tagged ??
then do one thing whenever the card is tagged then true action happens
like one example is whenever card is tagged the Rx pin goes "LOW" so that can also be a condition but as you are making on Security basis so you may go with it and then check for Card ID Number,
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top