- This topic has 1 reply, 2 voices, and was last updated 11 years ago by
Ashutosh Bhatt.
-
AuthorPosts
-
April 4, 2014 at 5:28 am #3016
yash mittal
Participantsir i have used microcontroller 8051 AT89S52 in my project .in my project there is a rfid tag which is need to be programmed using 8051 microcontroller .IN my project when the rfid tag is brought near to the rfid reader the screen of the led will show”TOTAL AMOUNT.”a beep sound will create and the motor will open the gate and the passenger will go into the metro.actually sir the code which i have used in my project i cannot understand it.please help me to understand it.sir i have pasted my code below .sir please explain this code at earliest to me.
// RFID BASED METRO TRAIN PROTOTYPE
#include<reg51.h>
sbit START_POINT=P3^2;
sbit TERMINATE_POINT=P3^3;
sbit S1=P0^0;
sbit S2=P0^1;
sbit S3=P0^2;
sbit S4=P0^4;
sbit BUZZPORT=P1^7;
sbit RS=P3^6;
sbit EN=P3^7;
void lcdinit();
void lcdData(unsigned char l);
void lcdcmd(unsigned char k);
void buzzer(unsigned int time);
void DelayMs(unsigned int count);
void display(unsigned char s, t, u,v);
void Welcome(unsigned char c[],unsigned char d[]);
void ConvertAndDisplay(signed int value1);
void delaysec(unsigned char i);
void dcMotor();
void main()
{
unsigned char i=0;
unsigned int j=0;
unsigned char c[15];
signed int amount1=1000;
signed int amount2=1000;
BUZZPORT=0;
S1=1;
S2=1;
S3=1;
S4=1;
lcdinit();
Welcome(“RFID BASED”,”METRO TRAIN PROTOTYPE:”);
DelayMs(1000);
while(1)
{
known:
while(1)
{
for(i=0;i<11;i++)
{
c=0xFF;
}
while(RI==0);
for(i=0;i<10;i++) //command to recv data
{
j=0;
while(RI==0)
{
if(j>=1000)
goto timeout;
DelayMs(1);
j++;
}
c=SBUF;
RI=0;
}
timeout:
for(i=0;i<15;i++)
{
if(c==’4′ && c[i+1]==’2′ && c[i+2]==’0′ && c[i+3]==’0′ && c[i+4]==’6′ && c[i+5]==’B’ && c[i+6]==’6′ && c[i+7]==’1′ && c[i+8]==’9′ && c[i+9]==’1′
)
{
lcdinit();
Welcome(“PRESS A BUTTON”,”TO ENTER STATION”);
while(S1==1 && S2==1 && S3==1 && S4==1);
if(S1==0)
{
while(S1==0);
Welcome(“STATION1 Amount:”,”Detected:10″);
DelayMs(1000);
amount2-=10;
}
if(S2==0)
{
while(S2==0);
Welcome(“STATION2 Amount:”,”Detected:20″);
DelayMs(1000);
amount2-=20;
}
if(S3==0)
{
while(S3==0);
Welcome(“STATION3 Amount:”,”Detected:30″);
DelayMs(1000);
amount2-=30;
}
if(S4==0)
{
while(S4==0);
Welcome(“STATION4 Amount:”,”Detected:40″);
DelayMs(1000);
amount2-=40;
}
if(amount2>=0)
{
ConvertAndDisplay(amount2);
dcMotor();
}
else
{
Welcome(“VISITOR A Amount:”,”BALANCE NIL”);
buzzer(10);
}
if(amount2==20)
{
Welcome(“VISITOR A Amount:”,”BALANCE LOW”);
buzzer(10);
}
DelayMs(1000);
goto known;
}
}
}
}
}
void Welcome(unsigned char c[],unsigned char d[])
{
unsigned int i=0;
lcdcmd(0x01);
DelayMs(10);
lcdcmd(0x80);
DelayMs(10);
i=0;
while(c!=’