EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / INTERFACING LCD TO 8051 BY Qurat-ul-ain

INTERFACING LCD TO 8051 BY Qurat-ul-ain

|

Microcontroller › 8051 › INTERFACING LCD TO 8051 BY Qurat-ul-ain

  • This topic has 23 replies, 12 voices, and was last updated 11 years, 8 months ago by Jaymin D.
Viewing 15 posts - 1 through 15 (of 24 total)
1 2 →
  • Author
    Posts
  • July 13, 2011 at 7:52 am #1173
    query
    Participant

     

    i am interfacing lcd to 8051. bt my lcd is showing just blocks. the code is
    perfect n the circuit is correctly patched. wat can be the reason?
    October 29, 2011 at 1:28 pm #6759
    nitin
    Participant

    dude after selection of line try giving initialisation command

    or else make initialisation a function and include in the select line function.

    try this…..

    good luck……..winkwinkwink

    October 29, 2011 at 3:27 pm #6760
    Qaisar
    Participant

    if u could put ur code here then its easy to find out the problem .. 

     

    October 29, 2011 at 3:32 pm #6761
    Qaisar
    Participant

     

     

    October 31, 2011 at 7:14 pm #6769
    sachin
    Participant

    same is proublem with mee… lcd showing only blocks…..i made 8051 based “A” chracter displaying on lcd….. from engg gagare site….plz help me….   i am just a begineer in microcontroller…………..

    November 1, 2011 at 4:41 am #6770
    Rogen Lee
    Participant

    same problem to our project also. The project were made is an liquid level alarm using the 8051 and the ouput we are using is an 16×2 lcd. We found out that the lcd was only light, it has no display. So, please help me to find the solution of our problem and so we can have a successfull project. Thank you.

    November 1, 2011 at 8:32 am #6771
    Qaisar
    Participant

    follow this code and diagram to display text and numbers on lcd..

     

     

    #include <AT89X51.H>
    #include < my.h > // built in delay function
     
    #define lcd_data P2
    sbit en=P0^1;
    sbit rs=P0^0;
     
     
    unsigned char z;
    unsigned int i;
     
             void lcdcmd(unsigned char value)
            {
                  lcd_data=value;
                   rs=0;
      en=1;
      delay(200);
      en=0;
      return;
     }
     
    void lcddata(unsigned char value)
    {
      lcd_data=value;
    rs=1;
    en=1;
    delay(200);
    en=0;
    return;
       }
     
    void main(void)
    {
       lcdcmd(0X38);//5X7 matrix
      lcdcmd(0X0E);//lcd on ,curor on
      lcdcmd(0X01); // clear lcd command
      lcdcmd(0X80);//move cursor to line1
     
      {
    unsigned char name[]=” TEST PROGRAMME “;
     
    for(z=0;z<=16;z++)
    lcddata(name[z]);
     
      lcdcmd(0XC2); // move cursor to line2, position 2
     
    for(i=48;i<=57;i++)
      lcddata(i);
     
    while(1);
     }
     
    } 
     
     
    wysiwyg_imageupload:3061:
    November 1, 2011 at 2:35 pm #6774
    sachin
    Participant

    i try to compile the program using keil uvision4,but these error occurs

     

    .
    7.c.c(3): warning C318: can’t open file ‘my.h’
    7.c.c(18): warning C206: ‘delay’: missing function-prototype
    7.c.c(18): error C267: ‘delay’: requires ANSI-style prototype
    Target not created

     

    what is its mean????

     

     

     

    but my program to show “A” character

    is there is any mictake plz tell meee…..

     

     

     

     

    #include<reg51.h>
    sfr lcd_data_pin=0xA0;
    sbit rs=P3^0;  //Register select pin
    sbit rw=P3^1;  // Read write pin
    sbit en=P3^6;  //Enable pin

    void delay(unsigned int count)  // Function to provide time delay in msec.
    {
    int i,j;
    for(i=0;i<count;i++)
      for(j=0;j<1275;j++);
    }

    void lcd_command(unsigned char comm)  //Function to send commands to LCD.
    {
    lcd_data_pin=comm;
    en=1;
    rs=0;
    rw=0;
    delay(1);
    en=0;
    }

    void lcd_data(unsigned char disp)  //Function to send data to LCD
    {
    lcd_data_pin=disp;
    en=1;
    rs=1;
    rw=0;
    delay(1);
    en=0;
    }

    void lcd_ini()  //Function to initialize the LCD
    {
    lcd_command(0x38); 
    delay(2);
    lcd_command(0x0F);
    delay(2);
    lcd_command(0x82);  //Set cursor to blink at line 1 positon 2
    delay(2);
    }

    void character()
    {
    lcd_command(64);  //Address where values of the first custom character is stored
    lcd_data(0);
    lcd_data(10);
    lcd_data(21);
    lcd_data(17);
    lcd_data(10);
    lcd_data(4);
    lcd_data(0);
    lcd_data(0);
    lcd_command(0xC0);  //Address of the location where the character is to be displayed
    lcd_data(0);  // Displaying the character created at address 0x64
    delay(10);

    lcd_command(72);
    lcd_data(0);
    lcd_data(0);
    lcd_data(0);
    lcd_data(10);
    lcd_data(0);
    lcd_data(4);
    lcd_data(17);
    lcd_data(14);
    lcd_command(0x80);
    lcd_data(1);
    delay(10);

    lcd_command(80);
    lcd_data(0);
    lcd_data(0);
    lcd_data(10);
    lcd_data(0);
    lcd_data(4);
    lcd_data(0);
    lcd_data(14);
    lcd_data(17);
    lcd_command(0x82);
    lcd_data(2);
    delay(10);
    lcd_command(88);
    lcd_data(1);
    lcd_data(3);
    lcd_data(5);
    lcd_data(9);
    lcd_data(9);
    lcd_data(11);
    lcd_data(27);
    lcd_data(24);
    lcd_command(0x84);
    lcd_data(3);
    delay(10);

    lcd_command(96);
    lcd_data(0);
    lcd_data(10);
    lcd_data(0);
    lcd_data(31);
    lcd_data(17);
    lcd_data(14);
    lcd_data(0);
    lcd_data(0);
    lcd_command(0x86);
    lcd_data(4);
    delay(10);

    lcd_command(104);
    lcd_data(10);
    lcd_data(0);
    lcd_data(4);
    lcd_data(0);
    lcd_data(14);
    lcd_data(17);
    lcd_data(17);
    lcd_data(14);
    lcd_command(0xC2);
    lcd_data(5);
    delay(10);

    lcd_command(112);
    lcd_data(0);
    lcd_data(10);
    lcd_data(0);
    lcd_data(0);
    lcd_data(4);
    lcd_data(0);
    lcd_data(31);
    lcd_data(0);
    lcd_command(0xC4);
    lcd_data(6);
    delay(10);

    lcd_command(120);
    lcd_data(0);
    lcd_data(17);
    lcd_data(10);
    lcd_data(17);
    lcd_data(4);
    lcd_data(0);
    lcd_data(14);
    lcd_data(17);
    lcd_command(0xC6);
    lcd_data(7);
    delay(10);
    }

    void main()
    {
    lcd_ini();
    character();
    }

    November 2, 2011 at 9:53 am #6778
    sourabh
    Participant

     

    try this
     
     
     
     
    #include<reg52.h>
    sbit rs   = P1^3;
    sbit rw   = P1^4;
    sbit en   = P1^6;
     
     
    int i;
     
    void delay(unsigned int);
    void data1();
    void cmd(int);
    void lcdin();
    void lcd(int);
     
    void main()
    {
      
      char *a;
     
      a=””;                                       //write your string here
      lcdin();
      
      for(i=0;a!=’’;i++)
      lcd(a);
       while(1);
    }
     
    void delay(unsigned int b)
    { int i,j;
       for(i=0;i<b;i++)
       for(j=0;j<1275;j++);
    }
     
    void data1()
    {
     rs=1;
     rw=0;
     en=1;
     delay(1);
     en=0;
     delay(1);
    }
     
     
    void cmd(int a)
    {
     P2=a;
     rs=0;
     rw=0;
     en=1;
     delay(1);
     en=0;
     delay(1);
    }
     
    void lcdin()
    {
     cmd(0x38);
     cmd(0x0e);
     cmd(0x01);
     cmd(0x06);
     cmd(0x80);
    }
     
    void lcd(int a)
    { 
      
      P2=a;
      data1();
    }
    November 2, 2011 at 9:58 am #6780
    sourabh
    Participant

    sachin the “my.h” file may be the user defined file of the user that’s why it is showing error in your system. He may have saved that module and is using it again for delay purposes.

    November 2, 2011 at 10:04 am #6781
    sourabh
    Participant

    Nitin if your circuit and code are proper then you try to change the contrast of your lcd or look at the screen at different angle, Sometimes it happens that due to contrast problem the characters are n;t visible. Or you try out with a different lcd, also check that is it properly soldered or not.

    November 2, 2011 at 3:04 pm #6788
    sachin
    Participant

    frend proublem is still same…

    plz send me hex code of this program….

    November 2, 2011 at 4:13 pm #6790
    sourabh
    Participant

    This is the content of hex file.  Save it in notepad with .hex format before burning it to your controller. Also I use at89s52 controller.

     

     :0F08AE006275737479206B69206D6973747900BA

    :100800007508FF750908750AAE12088BE4F50BF53B
    :100810000CAB08AA09A90A850C82850B831208363D
    :10082000FF60113395E0FE1208DF050CE50C70E166
    :06083000050B80DD80FED7
    :08086300C294D2967F017E00D1
    :10086B00E4FDFCC3ED9FEC9E5015E4FBFA0BBB00C3
    :0F087B00010ABA04F8BBFBF50DBD00010C80E4C7
    :01088A00224B
    :0A08D500D293120863C29602086B6A
    :0C08BD008FA0C293120863C29602086B61
    :10088B007F387E001208BD7F0E7E001208BD7F01EF
    :10089B007E001208BD7F067E001208BD7F807E00A1
    :0308AB000208BD83
    :0508DF008FA00208D506
    :030000000208C92A
    :0C08C900787FE4F6D8FD75810C02080071
    :10083600BB010CE58229F582E5833AF583E0225077
    :1008460006E92582F8E622BBFE06E92582F8E222C1
    :0D085600E58229F582E5833AF583E49322DB
    :00000001FF
     
    November 2, 2011 at 5:20 pm #6791
    Qaisar
    Participant

    my.h is delay file that exist in my Ex1 folder .

    open kiel folder then open  my Ex1 ,

    copy my.h file to ur project …or just use ur own delay routine…

     

    November 8, 2011 at 12:27 am #6810
    Rogen Lee
    Participant

    hello guys. Please help me how to display an lcd to our project. Here is the code of our project.

     

    #include<reg51.h>

    sbit rs=P1^0; //register select pin

    sbit rw=P1^1; //read/write pin

    sbit e=P1^2; //enable pin

    sbit quat=P3^0; //pin connected to quater level of tank

    sbit half=P3^1; //pin connected to half level of tank

    sbit quat_3=P3^2; //pin connected to three -fourth level of tank

    sbit full=P3^3; //pin connected to full level of tank

    sbit spkr_on=P3^4; 

    sbit spkr_off=P3^5; // pin to off speaker

     

    void delay(int k) //delay function

    {

    int i,j;

    for(i=0;i<k;i++)

      for(j=0;j<1275;j++);

    }

     

    void write(int j) //write function

    {

    rs=1;  //selecting command register

    rw=0;  //selecting to write

    P2=j;  //putting value on the pins

    e=1;  //strobe the enable pin

    delay(1);

    e=0;

    return;

    }

     

    void cmd(int j)  //command function

    {

    P2=j;  //put the value on pins

    rs=0;  //selecting command register

    rw=0;  //selecting to write

    e=1;  //strobe enable pin

    delay(1);

    e=0;

    return;

    }

     

    void puts(char *a) //puts function to print a string

    {

    unsigned int p=0;

    for(;a[p]!=0;p++)

    write(a[p]);

    }

     

    void lcd_init(void) // function to initialise the LCD

    {

    cmd(0x38); //setting 8-bit interface, 2 lines, 5*7 Pixels

    delay(1);

    cmd(0x0e); //turning on underline visible cursor

    delay(1);    

    cmd(0x01); //clearing screen

    cmd(0x80); //moving cursor to the begining of line 1 of LCD

    }

     

    void main()

    {

    quat=half=quat_3=full=spkr_off=1; //configuring as input pins

    quat=half=quat_3=full=spkr_off=0; //lowering input pins

    spkr_on=1;    // making speaker on pin high,as it works on negative logic

    while(1)

    {

      while(quat==0&&half==0&&quat_3==0&&full==0&&spkr_off==0)   //condition when tank is empty

      {

       lcd_init();        // initialising LCD

       puts(“VACANT”);       //printing VACANT on lcd

      }

      while(quat==1&&half==0&&quat_3==0&&full==0&&spkr_off==0)         //condition when tank is quater

      {

       lcd_init();

       puts(“QUATER”);      //printing QUATER on lcd

      }

      while(quat==1&&half==1&&quat_3==0&&full==0&&spkr_off==0)         //condition when tank is half

      {

       lcd_init();     

       puts(“HALF”);      //printing HALF on lcd

      }

      while(quat==1&&half==1&&quat_3==1&&full==0&&spkr_off==0)         //condition when tank is three-fourth

      {

       lcd_init();

       puts(“3/4 FULL”);     //printing 3/4 FULL on lcd

      }

      while(quat==1&&half==1&&quat_3==1&&full==1&&spkr_off==0)         //condition when tank is full

      {

       lcd_init();

       puts(“FULL;CLOSE TAP”);     //printing FULL;CLOSE TAP on lcd

       spkr_on=0;// Enabling speaker

      }

      while(quat==1&&half==1&&quat_3==1&&full==1&&spkr_on==0&&spkr_off==1)//enabling high speaker_off pin

      {

       spkr_on=1;//disabling speaker

      }

    }

    }

     

     

    I hope you can share your ideas. So, we can pass our project successfully. This is my first time to do the project using the microcontroller. so, please help me. Thank you

     

  • Author
    Posts
Viewing 15 posts - 1 through 15 (of 24 total)
1 2 →
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Project boxes March 13, 2026
  • Arduino standalone minimal March 13, 2026
  • Very Curious Issue With DS3231 RTC Clock March 13, 2026
  • Phone to op amp circuit? March 13, 2026
  • energising a solenoid March 12, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise