how to transmit data from RFID to lcd using 8051 in embeddedc language

Discussion in 'Embedded Systems and Microcontrollers' started by rockey bhardwaj, Sep 6, 2013.

  1. rockey bhardwaj

    Thread Starter New Member

    Sep 6, 2013
    1
    0
    Goodevening everyone


    I am making an attendence system using 8051.But Id number is not displaying on the lcd. i am using the controller 8051. But I am fail to receive the data on lcd . If anyone know to display the data on lcd. Then please help me.
    this is the code :

    Code ( (Unknown Language)):
    1.  
    2. //Program to interface RFID with 8051 microcontroller (AT89C51)
    3. #include<reg51.h>
    4. unsigned int data_out,command=0x80,temp;
    5. sfr lcd_data_pin=0xA0; //P2 port
    6. sbit rs=P1^0; //Register select
    7. sbit rw=P1^1; //Read/Write
    8. sbit en=P1^2; //Enable pin
    9. unsigned char card_id[12];
    10.  
    11. void delay(unsigned int count) //Function to provide delay
    12. {
    13. int i,j;
    14. for(i=0;i<count;i++)
    15. for(j=0;j<1275;j++);
    16. }
    17.  
    18. void lcd_command(unsigned char comm) //Lcd command funtion
    19. {
    20. lcd_data_pin=comm;
    21. en=1;
    22. rs=0;
    23. rw=0;
    24. delay(1);
    25. en=0;
    26. }
    27.  
    28. void lcd_data(unsigned char disp) //Lcd data function
    29. {
    30. lcd_data_pin=disp;
    31. en=1;
    32. rs=1;
    33. rw=0;
    34. delay(1);
    35. en=0;
    36. }
    37.  
    38. lcd_string(unsigned char *disp) //Function to send string
    39. {
    40. int x;
    41. for(x=0;disp[x]!=0;x++)
    42. {
    43. lcd_data(disp[x]);
    44. }
    45. }
    46. void lcd_ini() //Function to initialize the LCD
    47. {
    48. lcd_command(0x38);
    49. delay(5);
    50. lcd_command(0x0F);
    51. delay(5);
    52. lcd_command(0x80);
    53. delay(5);
    54. }
    55.  
    56. void recieve() //Function to recieve data serialy from RS232
    57. {
    58. unsigned char k;
    59. for(k=0;k<12;k++)
    60. {
    61. while(RI==0);
    62. card_id[k]=SBUF;
    63. RI=0;
    64. }
    65. }
    66.  
    67. void main()
    68. {
    69. int l;
    70. TMOD=0x20; //Enable Timer 1
    71. TH1=0XFD;
    72. SCON=0x50;
    73. TR1=1; // Triggering Timer 1
    74. lcd_ini();
    75. lcd_command(0x81); //Place cursor to second position of first line
    76. lcd_string("UNIQUE CARD ID:");
    77. delay(200);
    78. while(1)
    79. {
    80. recieve();
    81. lcd_command(0xC1); //Place cursor to second position of second line
    82. for(l=0;l<12;l++)
    83. {
    84. lcd_data(card_id[l]);
    85. }
    86. }
    87. }
    88.  
     
    Last edited by a moderator: Sep 6, 2013
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    There are tons of code examples on the web showing how to do this. The land mines in software usually concern the delays so make them generous for now. Single step the code and see if you are really changing the pics you need.

    The wiring is pretty straight forward, but I've still booted it on the 50th time doing it. Make sure you have the pot if your unit uses the pot (most do), all the pins are connected properly.

    Your code is near impossible to read as is. Please repost using code tags (the # icon on the advanced post window). Look up code tags if you do not understand.

    Do you set the direction of the I/O pins? I can't find that in your code.
     
  3. Arm_n_Legs

    Active Member

    Mar 7, 2007
    183
    10
Loading...