Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
SBUF = 'X'
void send_uart(void);
void send_string_uart(unsigned char string[])
unsigned char mystring[] = "AT89C51";
void send_uart(void) {
TI = 0;
SBUF = 'A';
while(TI == 0);
}
void send_string_uart(unsigned char string[]) {
unsigned int count;
for(count = 0; count < strlen(string); count++) {
TI = 0;
SBUF = string[count];
while(TI == 0);
}
}
void main() {
while(1) {
send_uart();
send_string_uart(mystring);
}
}
#include<reg51.h>
#include<intrins.h>
void delay (unsigned char);
void command (unsigned char);
void display (unsigned char);
sbit RS=P2^0;
sbit RW=P2^1;
sbit EN=P2^2;
sbit BUSY=P0^7;
unsigned char c,i,b,a,l,byte=0;
unsigned char card_id[8];
void command(unsigned char);
void recieve();
void lcd_string(unsigned char);
void ready();
void get();
unsigned char *disp[] ;
unsigned char tag[8]={'1','5','4','2','7','4','1','2'}; //for comparing the tag id which i receive from SBUF
unsigned char tag1[8]={'1','5','4','2','8','7','5','2'}; //for comparing the tag id which i receive from SBUF
void main()
{
P0=0x00;
TMOD=0x20;
TH1=0XFD;
SCON=0x50;
TR1=1;
command(0x38);
command(0x01);
command(0x0e);
command(0x06);
command(0x80);
command(0xc0);
IE=0X90;
while(1)
{
if(byte==8) // checking i'am getting 8 char from SBUF
{
get();
}
}
}
void lcd_string(unsigned char *disp)
{
int x;
for(x=0;disp[x]!=0;x++)
{
display(disp[x]);
}
}
void receive(void) interrupt 4 //SERIAL INTERRUPT
{
unsigned char k=0;
if(RI==1)
{
card_id[byte]=SBUF;
RI=0;
byte++;
}
}
void get() //FUNCTION TO COMPARE THE TAG ID AND DISPLAY IN LCD
{
unsigned char j,k,count=0,count1=0;
for(j=0;j<8;j++)
{
if(card_id[j]==tag[j])
{
count++;
}
}
for(k=0;k<8;k++)
{
if(card_id[k]==tag1[k])
{
count1++;
}
}
if(count==8)
{
lcd_string("BAGYA");
command(0xc7);
lcd_string("GRANTED");
}
else if(count1==8)
{
lcd_string("GOPI");
command(0xc7);
lcd_string("GRANTED");
}
else
{
command(0xc3);
lcd_string("WRONG ID");
}
}
void command (unsigned char a) //LCD COMMAND FUNCTION
{
ready();
RS=0;
RW=0;
P0=a;
EN=1;
_nop_();
_nop_();
EN=0;
}
void ready()
{
RS=0;
RW=1;
BUSY=1;
EN=0;
_nop_();
_nop_();
EN=1;
while(BUSY==1);
}
void display(unsigned char b)
{
ready();
RS=1;
RW=0;
P0=b;
EN=1;
_nop_();
_nop_();
EN=0;
}
#include<reg51.h>
#include<intrins.h>
void delay (unsigned char);
void command (unsigned char);
void display (unsigned char);
sbit RS=P2^0;
sbit RW=P2^1;
sbit EN=P2^2;
sbit BUSY=P0^7;
void command(unsigned char);
void recieve();
void lcd_string(unsigned char);
void ready();
void get();
unsigned char c,i,b,a,l,byte=0;
unsigned char card_id[8];
unsigned char *disp[];
unsigned char tag[8]={'1','5','4','2','7','4','1','2'}; //for comparing the tag id which i
//receive from SBUF
unsigned char tag1[8]={'1','5','4','2','8','7','5','2'}; //for comparing the tag id which i
//receive from SBUF
void main()
{
P0=0x00;
P3=0x03;
TMOD=0x20;
TH1=0XFD;
SCON=0x50;
TR1=1;
command(0x38);
command(0x01);
command(0x0e);
command(0x06);
command(0x80);
command(0xc0);
IE=0X90;
while(1)
{
if(byte==8) // checking i'am getting 8 char from SBUF
{
get();
break;
}
}
}
void lcd_string(unsigned char *disp)
{
int x;
for(x=0;disp[x]!=0;x++)
{
display(disp[x]);
}
}
void receive(void) interrupt 4 //SERIAL INTERRUPT
{
unsigned char k=0;
if(RI==1)
{
card_id[byte]=SBUF;
RI=0;
byte++;
}
}
void get() //FUNCTION TO COMPARE THE TAG ID AND DISPLAY IN LCD
{
unsigned char j,k,count=0,count1=0;
for(j=0;j<8;j++)
{
if(card_id[j]==tag[j])
{
count++;
}
}
for(k=0;k<8;k++)
{
if(card_id[k]==tag1[k])
{
count1++;
}
}
if(count==8)
{
lcd_string("BAGYA");
command(0xc7);
lcd_string("GRANTED");
}
else if(count1==8)
{
lcd_string("GOPI");
command(0xc7);
lcd_string("GRANTED");
}
else
{
command(0xc3);
lcd_string("WRONG ID");
}
}
void command (unsigned char a) //LCD COMMAND FUNCTION
{
ready();
RS=0;
RW=0;
P0=a;
EN=1;
_nop_();
_nop_();
EN=0;
}
void ready()
{
RS=0;
RW=1;
BUSY=1;
EN=0;
_nop_();
_nop_();
EN=1;
while(BUSY==1);
}
void display(unsigned char b)
{
ready();
RS=1;
RW=0;
P0=b;
EN=1;
_nop_();
_nop_();
EN=0;
}
#include<reg51.h>
#include<intrins.h>
void delay (unsigned char);
void command (unsigned char);
void display (unsigned char);
sbit RS=P2^0;
sbit RW=P2^1;
sbit EN=P2^2;
sbit BUSY=P0^7;
void command(unsigned char);
void recieve();
void lcd_string(unsigned char);
void lcd_array(unsigned char data[]);
void ready();
void get();
unsigned char c,i,b,a,l,byte=0;
unsigned char card_id[8];
unsigned char *disp[];
unsigned char tag[8]={'1','5','4','2','7','4','1','2'}; //for comparing the tag id which i
//receive from SBUF
unsigned char tag1[8]={'1','5','4','2','8','7','5','2'}; //for comparing the tag id which i
//receive from SBUF
void main()
{
P0=0x00;
P3=0x03;
TMOD=0x20;
TH1=0XFD;
SCON=0x50;
TR1=1;
command(0x38);
command(0x01);
command(0x0e);
command(0x06);
command(0x80);
command(0xc0);
IE=0X90;
command(0x80);
lcd_string("Swipe RFID Card");
while(1)
{
if(byte!=8)
{
command(0x80);
lcd_string("Swipe your Card");
}
if(byte==8) // checking i'am getting 8 char from SBUF
{
get();
}
}
}
void lcd_array(unsigned char data[])
{
int x;
for(x=0;x<8;x++)
{
display(data[x]);
}
}
void lcd_string(unsigned char *disp)
{
int x;
for(x=0;disp[x]!=0;x++)
{
display(disp[x]);
}
}
void receive(void) interrupt 4 //SERIAL INTERRUPT
{
unsigned char k=0;
if(RI==1)
{
card_id[byte]=SBUF;
RI=0;
byte++;
}
}
void get() //FUNCTION TO COMPARE THE TAG ID AND DISPLAY IN LCD
{
unsigned char j,k,count=0,count1=0;
for(j=0;j<8;j++)
{
if(card_id[j]==tag[j])
{
count++;
}
}
for(k=0;k<8;k++)
{
if(card_id[k]==tag1[k])
{
count1++;
}
}
//lcd_array(card_id);
//delay(500);
if(count==8)
{
lcd_string("BAGYA");
command(0xc7);
lcd_string("GRANTED");
}
else if(count1==8)
{
lcd_string("GOPI");
command(0xc7);
lcd_string("GRANTED");
}
else
{
command(0xc3);
lcd_string("WRONG ID");
}
byte = 0;
}
void command (unsigned char a) //LCD COMMAND FUNCTION
{
ready();
RS=0;
RW=0;
P0=a;
EN=1;
_nop_();
_nop_();
EN=0;
}
void ready()
{
RS=0;
RW=1;
BUSY=1;
EN=0;
_nop_();
_nop_();
EN=1;
while(BUSY==1);
}
void display(unsigned char b)
{
ready();
RS=1;
RW=0;
P0=b;
EN=1;
_nop_();
_nop_();
EN=0;
}
if(byte==8) // checking i'am getting 8 char from SBUF
{
get();
}
if(byte==8) // checking i'am getting 8 char from SBUF
{
get();
// add a 2 sec delay here
}