RFID with Pic16f877A (problem)

mikroC, mikroBasic and mikroPascal PRO for Microchip’s 8-bit PIC MCUs.
Post Reply
Author
Message
Ahmed99
Posts: 1
Joined: 26 May 2021 11:06

RFID with Pic16f877A (problem)

#1 Post by Ahmed99 » 26 May 2021 18:50

Hi dear all,

I have been working on my school project for couple of weeks and I'm trying to make RFID Door Lock by using Pic16f877A and RDM6300 RFID reader , I made a code works on PROTUS but I interfaced the cards tags as decimal number like(123456) and after that I noticed that all RF cards have HEX value like (B5:CF:79:23)
now I want to store my cards tag in the code and if i put the card on the RFID antenna it should be works if the card its correct
may you guide me to store my card tags on the program (B5:CF:79:23)👏

my code

Code: Select all

sbit LCD_RS at RD2_bit;
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;

sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
void main()
    {
     unsigned char  i, rfid[13];
     //char String[8]= "B5:CF:79:23";
     int abdo =54321;
     int islam =12345;
     int y;
     Lcd_Init();
     trisc.RC3=0;
     portc.RC3=0;
     portc.RC4=0;
     trisc.RC4=0;
     portc.RC5=0;
     trisc.RC5=0;                     // Initialize LCD
     Lcd_Cmd(_LCD_CLEAR);              // Clear display
     Lcd_Cmd(_LCD_CURSOR_OFF);         // Cursor off
     Lcd_Out(1,1,"RFID Tag Reader");   // Write text in first row
     UART1_Init(9600);                 // Initialize UART, 9600 baud rate
     rfid[12] = '\0';                  // String Terminating Character
       while(1)                        // Infinite Loop
      {
        if (UART1_Data_Ready())        // If UART Data Ready
        {

          for(i=0;i<5;)                // To Read 5 characters
          {
            if (UART1_Data_Ready())
            {
                  rfid[i] = UART1_Read();
                  i++;
            }
          }
          Lcd_Cmd(_LCD_CLEAR);              // Clear display
          Lcd_Cmd(_LCD_CURSOR_OFF);         // Cursor off
          Lcd_Out(1,1,"  << Welcome >>");   // Write text in first row
          Lcd_Cmd(_LCD_SECOND_ROW);
          Lcd_Out_cp("  Card ID:");
          for(i=0;i<5;)
          {
            Lcd_Chr_Cp(rfid[i]);
            UART1_Write(rfid[i]);
            i++;
            delay_us(1000);
          }
            y = atoi(&rfid);
            if( islam == y )
            {
              Lcd_Out(1,1,"  Welcome ISlAM  ");
              portc.RC5 =0;
              portc.RC3 =1;
               if(portc.RC3 =1)
              {
                portc.RC4 =1;
                delay_ms(200);
                portc.RC4 =0;
              }
            }
            else if( abdo == y )
            {
              Lcd_Out(1,1,"  Welcome ABDO  ");
              portc.RC5 =0;
              portc.RC3 =1;
              if(portc.RC3 =1)
              {
                portc.RC4 =1;
                delay_ms(200);
                portc.RC4 =0;
              }
            }
            else
             {
                portc.RC3 =0;
                portc.RC4 =0;
                portc.RC5 =1;
                if(portc.RC5 =1)
                {
                  portc.RC4 =1;
                  delay_ms(600);
                  portc.RC4 =0;

                  delay_ms(200);
                }
                Lcd_Out(1,1,"Check Your Card");
             }
              delay_ms(2000);
        }
        else
        {
          portc.RC3 =0;
          portc.RC4 =0;
          portc.RC5 =1;
          Lcd_Out(1,1,"  << Welcome >>  ");
          Lcd_Cmd(_LCD_SECOND_ROW);
          Lcd_Out(2,2,"Press Your Card  ");
         }
     }
   }


Attachments
1234.jpg
1234.jpg (335.5 KiB) Viewed 1382 times

Post Reply

Return to “PIC PRO Compilers”