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.

[SOLVED] This is reading rfid but not comparing why?

Status
Not open for further replies.
Joined
Jul 25, 2012
Messages
1,192
Helped
171
Reputation
342
Reaction score
162
Trophy points
1,343
Activity points
0
Hello!

This code is reading rfid and displaying it, but comparing it with tag array fails. why?

tag = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3 }
card_id holds the read rfid.

rfid entered through virtual terminal is 123456789123

here is the code

Code:
#include<reg51.h>

//Function declarations
void cct_init(void);
void delay(int);
void lcdinit(void);
void writecmd(int);
void writedata(char);
void ReturnHome(void);
void display();
void display2();

//*******************
//Pin description
/*
P2.4 to P2.7 is data bus
P1.0 is RS
P1.1 is E
*/
//********************

// Defines Pins
sbit RS = P1^0;
sbit E  = P1^1;

unsigned char card_id[12];
unsigned char tag[12] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3 };
unsigned char read_id[12];
unsigned char current_byte = 0;
unsigned int display_flag = 0;
unsigned int key = 0;
unsigned int count = 0;


void recieve() interrupt 4     //Function to recieve data serialy from RS232 
{
        card_id[current_byte]=SBUF;
        RI=0;                // Reset the serial interrupt after recieving the byte
        current_byte++;    
}

// ***********************************************************
// Main program
//
void main(void)
{
	 cct_init();                                     //Make all ports zero
   
	 TMOD=0x20;                            //Enable Timer 1
   TH1=0XFD;
   SCON=0x50;
   TR1=1;
   EA=1;
   ES=1;
	 
	 lcdinit();                                      //Initilize LCD
	 
   writedata('U');                                 //write
   writedata('n');                                 //write
   writedata('i');                                 //write
   writedata('q');                                 //write
   writedata('u');                                 //write
   writedata('e');                                 //write
   writedata(' ');                                 //write
   writedata('C');                                 //write
   writedata('a');                                 //write
   writedata('r');                                 //write
   writedata('d');                                 //write
   writedata(' ');                                 //write
	 writedata('I');                                 //write
   writedata('d'); 

   ReturnHome();                                   //Return to 0 position
			
	while(1)
	{
		while(current_byte!=12);
		display();
		delay(50000);
		
		key=0;
		for(count=0;count<12;count++)
		{ 
		   if(card_id[count]==tag[count])
			{
			 key++;
			}
		}	
		
		count = 0;
		
		if(key == 12) {
				display2();
			  display_flag = 1;
		}	
		
		
		/*
		if((tag == card_id) && (display_flag == 0)) {
			  display2();
			  display_flag = 1;
		}
		*/
				
	}

}


void display()        // Function to display the unique id
{
    unsigned char count;
    writecmd(0xC1);        //Place cursor to second position of second line
    for(count=0;count<12;count++)
     { 		
				          writedata(card_id[count]);
									//read_id[count] = card_id[count] + 48;
		 }
    current_byte=0;
}


void display2()        // Function to display the unique id
{
    unsigned char count;
    writecmd(0xC1);        //Place cursor to second position of second line
    for(count=0;count<12;count++)
     { 		
				    //writedata(tag[count]);
						writedata('C');                                 //write
						writedata('a');                                 //write
						writedata('r');                                 //write
						writedata('d');                                 //write
						writedata(' ');                                 //write
						writedata('A');                                 //write
						writedata('c');                                 //write
						writedata('c');                                 //write
						writedata('e');                                 //write
						writedata('p');                                 //write
						writedata('t');                                 //write
						writedata('e');                                 //write
						writedata('d');                                 //write
		 }
}



void cct_init(void)
{
P0 = 0x00;   //not used 
P1 = 0x00;   //not used 
P2 = 0x00;   //used as data port
P3 = 0x00;   //used for generating E and RS
}

void delay(int a)
{
   int i;
   for(i=0;i<a;i++);   //null statement
}

void writedata(char t)
{
   RS = 1;             // This is data

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= (t&0xF0);     // Write Upper nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= ((t<<4)&0xF0);// Write Lower nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);
}


void writecmd(int z)
{
   RS = 0;             // This is command

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= (z&0xF0);     // Write Upper nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= ((z<<4)&0xF0);// Write Lower nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);
}

void lcdinit(void)
{
  ///////////// Reset process from datasheet /////////
     delay(15000);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x30&0xF0);    // Write 0x3
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

     delay(4500);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x30&0xF0);    // Write 0x3
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

     delay(300);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x30&0xF0);    // Write 0x3
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

     delay(650);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x20&0xF0);    // Write 0x2
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

	 delay(650);

  /////////////////////////////////////////////////////
   writecmd(0x28);    //function set
   writecmd(0x0c);    //display on,cursor off,blink off
   writecmd(0x01);    //clear display
   writecmd(0x06);    //entry mode, set increment
}

void ReturnHome(void)     //Return to 0 location
{
  writecmd(0x02);
    delay(1500);
}

OK. rfid v2.rar is working but It is displaying Card Accepted 4 to 5 times. why?

Code:
#include<reg51.h>

//Function declarations
void cct_init(void);
void delay(int);
void lcdinit(void);
void writecmd(int);
void writedata(char);
void ReturnHome(void);
void display();
void display2();

//*******************
//Pin description
/*
P2.4 to P2.7 is data bus
P1.0 is RS
P1.1 is E
*/
//********************

// Defines Pins
sbit RS = P1^0;
sbit E  = P1^1;

unsigned char card_id[12];
unsigned char tag[12] = { 49, 50, 51, 52, 53, 54, 55, 56, 57, 49, 50, 51 };
unsigned char read_id[12];
unsigned char current_byte = 0;
unsigned int display_flag = 0;
unsigned int key = 0;
unsigned int count = 0;


void recieve() interrupt 4     //Function to recieve data serialy from RS232 
{
        card_id[current_byte]=SBUF;
        RI=0;                // Reset the serial interrupt after recieving the byte
        current_byte++;    
}

// ***********************************************************
// Main program
//
void main(void)
{
	 cct_init();                                     //Make all ports zero
   
	 TMOD=0x20;                            //Enable Timer 1
   TH1=0XFD;
   SCON=0x50;
   TR1=1;
   EA=1;
   ES=1;
	 
	 lcdinit();                                      //Initilize LCD
	 
   writedata('U');                                 //write
   writedata('n');                                 //write
   writedata('i');                                 //write
   writedata('q');                                 //write
   writedata('u');                                 //write
   writedata('e');                                 //write
   writedata(' ');                                 //write
   writedata('C');                                 //write
   writedata('a');                                 //write
   writedata('r');                                 //write
   writedata('d');                                 //write
   writedata(' ');                                 //write
	 writedata('I');                                 //write
   writedata('d'); 

   ReturnHome();                                   //Return to 0 position
			
	while(1)
	{
		while(current_byte!=12);
		display();
		delay(500000);
		
		key=0;
		for(count=0;count<12;count++)
		{ 
		   if(card_id[count]==tag[count])
			{
			 key++;
			}
		}	
		
		count = 0;
		
		if((key == 12) && (display_flag == 0)) {
				delay(500000);
				display2();
			  display_flag = 1;
			  key = 0;
			  break;
		}	
		
		
		/*
		if((tag == card_id) && (display_flag == 0)) {
			  display2();
			  display_flag = 1;
		}
		*/
				
	}

}


void display()        // Function to display the unique id
{
    unsigned char count;
    writecmd(0xC1);        //Place cursor to second position of second line
    for(count=0;count<12;count++)
     { 		
				          writedata(card_id[count]);
									//read_id[count] = card_id[count] + 48;
		 }
    current_byte=0;
}


void display2()        // Function to display the unique id
{
    unsigned char count;
    writecmd(0xC1);        //Place cursor to second position of second line
    for(count=0;count<12;count++)
     { 		
				    //writedata(tag[count]);
						writedata('C');                                 //write
						writedata('a');                                 //write
						writedata('r');                                 //write
						writedata('d');                                 //write
						writedata(' ');                                 //write
						writedata('A');                                 //write
						writedata('c');                                 //write
						writedata('c');                                 //write
						writedata('e');                                 //write
						writedata('p');                                 //write
						writedata('t');                                 //write
						writedata('e');                                 //write
						writedata('d');                                 //write
		 }
}



void cct_init(void)
{
P0 = 0x00;   //not used 
P1 = 0x00;   //not used 
P2 = 0x00;   //used as data port
P3 = 0x00;   //used for generating E and RS
}

void delay(int a)
{
   int i;
   for(i=0;i<a;i++);   //null statement
}

void writedata(char t)
{
   RS = 1;             // This is data

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= (t&0xF0);     // Write Upper nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= ((t<<4)&0xF0);// Write Lower nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);
}


void writecmd(int z)
{
   RS = 0;             // This is command

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= (z&0xF0);     // Write Upper nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= ((z<<4)&0xF0);// Write Lower nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);
}

void lcdinit(void)
{
  ///////////// Reset process from datasheet /////////
     delay(15000);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x30&0xF0);    // Write 0x3
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

     delay(4500);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x30&0xF0);    // Write 0x3
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

     delay(300);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x30&0xF0);    // Write 0x3
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

     delay(650);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x20&0xF0);    // Write 0x2
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

	 delay(650);

  /////////////////////////////////////////////////////
   writecmd(0x28);    //function set
   writecmd(0x0c);    //display on,cursor off,blink off
   writecmd(0x01);    //clear display
   writecmd(0x06);    //entry mode, set increment
}

void ReturnHome(void)     //Return to 0 location
{
  writecmd(0x02);
    delay(1500);
}

OK. rfid v3.rar is working. The problem got fixed, but It is displaying Unique Card Id after displaying Card Accepted. why?

Is the mcu resetting?

Code:
#include<reg51.h>

//Function declarations
void cct_init(void);
void delay(int);
void lcdinit(void);
void writecmd(int);
void writedata(char);
void ReturnHome(void);
void display();
void display2();

//*******************
//Pin description
/*
P2.4 to P2.7 is data bus
P1.0 is RS
P1.1 is E
*/
//********************

// Defines Pins
sbit RS = P1^0;
sbit E  = P1^1;

unsigned char card_id[12];
unsigned char tag[12] = { 49, 50, 51, 52, 53, 54, 55, 56, 57, 49, 50, 51 };
unsigned char read_id[12];
unsigned char current_byte = 0;
unsigned int display_flag = 0;
unsigned int key = 0;
unsigned int count = 0;


void recieve() interrupt 4     //Function to recieve data serialy from RS232 
{
        card_id[current_byte]=SBUF;
        RI=0;                // Reset the serial interrupt after recieving the byte
        current_byte++;    
}

// ***********************************************************
// Main program
//
void main(void)
{
	 cct_init();                                     //Make all ports zero
   
	 TMOD=0x20;                            //Enable Timer 1
   TH1=0XFD;
   SCON=0x50;
   TR1=1;
   EA=1;
   ES=1;
	 
	 lcdinit();                                      //Initilize LCD
	 
   writedata('U');                                 //write
   writedata('n');                                 //write
   writedata('i');                                 //write
   writedata('q');                                 //write
   writedata('u');                                 //write
   writedata('e');                                 //write
   writedata(' ');                                 //write
   writedata('C');                                 //write
   writedata('a');                                 //write
   writedata('r');                                 //write
   writedata('d');                                 //write
   writedata(' ');                                 //write
	 writedata('I');                                 //write
   writedata('d'); 

   ReturnHome();                                   //Return to 0 position
			
	while(1)
	{
		while(current_byte!=12);
		display();
		delay(500000);
		
		key=0;
		for(count=0;count<12;count++)
		{ 
		   if(card_id[count]==tag[count])
			{
			 key++;
			}
		}	
		
		count = 0;
		
		if((key == 12) && (display_flag == 0)) {
				delay(500000);
				display2();
			  display_flag = 1;
			  key = 0;
			  break;
		}	
		
		
		/*
		if((tag == card_id) && (display_flag == 0)) {
			  display2();
			  display_flag = 1;
		}
		*/
				
	}

}


void display()        // Function to display the unique id
{
    unsigned char count;
    writecmd(0xC1);        //Place cursor to second position of second line
    for(count=0;count<12;count++)
     { 		
				          writedata(card_id[count]);
									//read_id[count] = card_id[count] + 48;
		 }
    current_byte=0;
}


void display2()        // Function to display the unique id
{
    //unsigned char count;
    writecmd(0xC1);        //Place cursor to second position of second line
    //for(count=0;count<12;count++)
     //{ 		
				    //writedata(tag[count]);
						writedata('C');                                 //write
						writedata('a');                                 //write
						writedata('r');                                 //write
						writedata('d');                                 //write
						writedata(' ');                                 //write
						writedata('A');                                 //write
						writedata('c');                                 //write
						writedata('c');                                 //write
						writedata('e');                                 //write
						writedata('p');                                 //write
						writedata('t');                                 //write
						writedata('e');                                 //write
						writedata('d');                                 //write
		 //}
}



void cct_init(void)
{
P0 = 0x00;   //not used 
P1 = 0x00;   //not used 
P2 = 0x00;   //used as data port
P3 = 0x00;   //used for generating E and RS
}

void delay(int a)
{
   int i;
   for(i=0;i<a;i++);   //null statement
}

void writedata(char t)
{
   RS = 1;             // This is data

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= (t&0xF0);     // Write Upper nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= ((t<<4)&0xF0);// Write Lower nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);
}


void writecmd(int z)
{
   RS = 0;             // This is command

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= (z&0xF0);     // Write Upper nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= ((z<<4)&0xF0);// Write Lower nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);
}

void lcdinit(void)
{
  ///////////// Reset process from datasheet /////////
     delay(15000);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x30&0xF0);    // Write 0x3
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

     delay(4500);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x30&0xF0);    // Write 0x3
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

     delay(300);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x30&0xF0);    // Write 0x3
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

     delay(650);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x20&0xF0);    // Write 0x2
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

	 delay(650);

  /////////////////////////////////////////////////////
   writecmd(0x28);    //function set
   writecmd(0x0c);    //display on,cursor off,blink off
   writecmd(0x01);    //clear display
   writecmd(0x06);    //entry mode, set increment
}

void ReturnHome(void)     //Return to 0 location
{
  writecmd(0x02);
    delay(1500);
}

OK. The problem got solved. It was the break; statement

Here is the working code and project files rfid worling.rar

Code:
#include<reg51.h>

//Function declarations
void cct_init(void);
void delay(int);
void lcdinit(void);
void writecmd(int);
void writedata(char);
void ReturnHome(void);
void display();
void display2();

//*******************
//Pin description
/*
P2.4 to P2.7 is data bus
P1.0 is RS
P1.1 is E
*/
//********************

// Defines Pins
sbit RS = P1^0;
sbit E  = P1^1;

unsigned char card_id[12];
unsigned char tag[12] = { 49, 50, 51, 52, 53, 54, 55, 56, 57, 49, 50, 51 };
unsigned char read_id[12];
unsigned char current_byte = 0;
unsigned int display_flag = 0;
unsigned int key = 0;
unsigned int count = 0;


void recieve() interrupt 4     //Function to recieve data serialy from RS232 
{
        card_id[current_byte]=SBUF;
        RI=0;                // Reset the serial interrupt after recieving the byte
        current_byte++;    
}

// ***********************************************************
// Main program
//
void main(void)
{
	 cct_init();                                     //Make all ports zero
   
	 TMOD=0x20;                            //Enable Timer 1
   TH1=0XFD;
   SCON=0x50;
   TR1=1;
   EA=1;
   ES=1;
	 
	 lcdinit();                                      //Initilize LCD
	 
   writedata('U');                                 //write
   writedata('n');                                 //write
   writedata('i');                                 //write
   writedata('q');                                 //write
   writedata('u');                                 //write
   writedata('e');                                 //write
   writedata(' ');                                 //write
   writedata('C');                                 //write
   writedata('a');                                 //write
   writedata('r');                                 //write
   writedata('d');                                 //write
   writedata(' ');                                 //write
	 writedata('I');                                 //write
   writedata('d'); 

   ReturnHome();                                   //Return to 0 position
			
	while(1)
	{
		while(current_byte!=12);
		display();
		delay(500000);
		
		key=0;
		for(count=0;count<12;count++)
		{ 
		   if(card_id[count]==tag[count])
			{
			 key++;
			}
		}	
		
		count = 0;
		
		if((key == 12) && (display_flag == 0)) {
				delay(500000);
				display2();
			  display_flag = 1;
			  key = 0;
		}	
		
		
		/*
		if((tag == card_id) && (display_flag == 0)) {
			  display2();
			  display_flag = 1;
		}
		*/
				
	}

}


void display()        // Function to display the unique id
{
    unsigned char count;
    writecmd(0xC1);        //Place cursor to second position of second line
    for(count=0;count<12;count++)
     { 		
				          writedata(card_id[count]);
									//read_id[count] = card_id[count] + 48;
		 }
    current_byte=0;
}


void display2()        // Function to display the unique id
{
    //unsigned char count;
    writecmd(0xC1);        //Place cursor to second position of second line
    //for(count=0;count<12;count++)
     //{ 		
				    //writedata(tag[count]);
						writedata('C');                                 //write
						writedata('a');                                 //write
						writedata('r');                                 //write
						writedata('d');                                 //write
						writedata(' ');                                 //write
						writedata('A');                                 //write
						writedata('c');                                 //write
						writedata('c');                                 //write
						writedata('e');                                 //write
						writedata('p');                                 //write
						writedata('t');                                 //write
						writedata('e');                                 //write
						writedata('d');                                 //write
		 //}
}



void cct_init(void)
{
P0 = 0x00;   //not used 
P1 = 0x00;   //not used 
P2 = 0x00;   //used as data port
P3 = 0x00;   //used for generating E and RS
}

void delay(int a)
{
   int i;
   for(i=0;i<a;i++);   //null statement
}

void writedata(char t)
{
   RS = 1;             // This is data

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= (t&0xF0);     // Write Upper nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= ((t<<4)&0xF0);// Write Lower nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);
}


void writecmd(int z)
{
   RS = 0;             // This is command

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= (z&0xF0);     // Write Upper nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= ((z<<4)&0xF0);// Write Lower nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);
}

void lcdinit(void)
{
  ///////////// Reset process from datasheet /////////
     delay(15000);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x30&0xF0);    // Write 0x3
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

     delay(4500);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x30&0xF0);    // Write 0x3
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

     delay(300);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x30&0xF0);    // Write 0x3
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

     delay(650);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x20&0xF0);    // Write 0x2
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

	 delay(650);

  /////////////////////////////////////////////////////
   writecmd(0x28);    //function set
   writecmd(0x0c);    //display on,cursor off,blink off
   writecmd(0x01);    //clear display
   writecmd(0x06);    //entry mode, set increment
}

void ReturnHome(void)     //Return to 0 location
{
  writecmd(0x02);
    delay(1500);
}
 

Attachments

  • rfid v1.rar
    51.7 KB · Views: 106
  • rfid reading.jpg
    rfid reading.jpg
    202 KB · Views: 108
  • rfid v2.rar
    51.7 KB · Views: 96
  • rfid v3.rar
    51.7 KB · Views: 94
  • rfid_reader2.rar
    13.7 KB · Views: 112
  • rfid working.rar
    65.8 KB · Views: 95
  • rfid sim.rar
    152 KB · Views: 95
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top