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 / How to interface 4bit mode LCD to 8051 Micro controller

How to interface 4bit mode LCD to 8051 Micro controller

|

Microcontroller › 8051 › How to interface 4bit mode LCD to 8051 Micro controller

  • This topic has 12 replies, 9 voices, and was last updated 12 years, 8 months ago by umar farrok.
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • July 25, 2011 at 9:41 am #3838
    Ramu Rachakonda
    Participant

    Please any body help me

    July 25, 2011 at 12:59 pm #6517
    Anonymous
    Guest

    its not that difficult if you know how to work in 8-bit mode. You just need to know how 4-bit Mode works for the LCD.

    Refer http://www.engineersgarage.com/embedded/avr-microcontroller-projects/interface-lcd-4bit-mode-circuit to understand the 4-bit mode working.

    July 26, 2011 at 11:12 am #6520
    Ramu Rachakonda
    Participant

    Hi very tanx for ur reply

     

     

     

     

     

     

     

    i tried 4bit mode program but in LCD no display.

     

     

     

     

    Actually my project is interfacing LM35 with C8052f120 Controller, so i interfaced LM35 to ADC of controller i got correct value in output side but that value i am not able to show in LCD so please help me.

     

     

     

    with Regards

    Ram.R

    July 27, 2011 at 5:33 am #6525
    dagakshay
    Participant

    hi Ramu,

    what problem you facing not gettin the number or not getting any display on LCD????…

    the link given aforside is a very nice one and properly explain i tried it and its workin well… i ask you to check you connects ones aagin….

    July 28, 2011 at 9:26 am #6542
    Ramu Rachakonda
    Participant

    Hi guys..

     

     

     I got LM35 interfacing to controller and 4bit mode LCD display successfully………..

     

     

     

     

     

    Thanks.. 

    July 28, 2011 at 9:55 am #6543
    Ramu Rachakonda
    Participant

    Hi guys..

     

     

     

    can anybody tell me keyboard interfacing procedure bcoz of i am new to prgrmng…

     

     

    Thanks.. 

    August 3, 2011 at 1:14 pm #6568
    romel emperado
    Participant

    here:

    very good example and explanation

     

    http://adf.ly/2Gy8n

    October 20, 2012 at 6:02 pm #8677
    raju
    Participant

     sir i want to  4 bit lcd display how to interface and correct coding for 4bit interface with 8051.

    October 20, 2012 at 6:06 pm #8678
    raju
    Participant

    any one tell me where i mistake in code pleace see my code.

     

    #include<reg51.h>
    #include<stdio.h>

    sbit rs=P3^7;
    sbit en=P3^6;
    #define port P1

    void delayms(int delay);
    void lcdcmd(unsigned char l);
    void lcddata(unsigned char l);
    void display(unsigned char *dr);
    void delay(unsigned char s);
    void lcd();
    void enable();
    void lcdint();

    void enable()
    {
    en=0;
    delay(100);
    en=1;
    }
    void lcdcmd(unsigned char l)
    {

    int s;
    rs=0;
    s=l;
    port=((l>>4)&0x0F);
    enable();
    delay(1000);
    enable();
    port=(s&0x0F);
    enable();
    //enable();

    }

    void lcddata(unsigned char l)
    {
    int s;
    rs=1;
    s=l;
    port=((l>>4)&0x0F);
    enable();
    delay(1000);
    enable();
    port=(s&0x0F);
    enable();
    //enable();

    }

    void display(unsigned char *dr)
    {

    while(*dr)
    {
    lcddata(*dr++);
    }
    }

    void delay(unsigned char s)
    {
    while(s–);
    }
    void lcd()
    {
    port=0xFF;
    enable();
    delayms(7);
    port=0x30;
    enable();
    delayms(5);
    port=0x30;
    enable();
    delayms(5);
    port=0x30;
    enable();
    delayms(5);
    port=0x20;
    enable();
    delayms(5);

    }
    void lcdint()
    {
    lcd();
    lcdcmd(0x28);
    delay(100);
    lcdcmd(0x0C);
    delay(500);
    lcdcmd(0x06);
    delay(500);
    //lcdcmd(0x01);
    delay(500);

    }

    void main()
    {

    while(1)
    {

    lcdint();
    lcdcmd(0x80);
    lcddata(‘a’);
    }
    }

    void delayms(int delay)
    {

    int i ;
    for(i = 0 ; i<delay ; i++)
    {
    TMOD=0x01;
    TH0 = 0xFC ;
    TL0 = 0x17 ;
    TR0 = 1 ;
    while(!TF0);
    TR0 = 0 ;
    TF0 = 0 ;
    }
    }

    October 21, 2012 at 8:08 am #8679
    AJISH ALFRED
    Participant

    Hi Raju,

    Post your schematic and the trouble you are having with the code

    March 5, 2013 at 11:05 pm #9255
    kunal
    Participant

     

    #include<reg51.h>
    #define port P3            //14,13,12,11 pins of lcd and 1.7,1.6,1.5,1.4 of controller
     
    #define lcdport P1
    sbit rs = port^0;
    sbit rw = port^1;
    sbit en = port^2;
     
    void lcd_ini();
    void dis_cmd(unsigned char);
    void dis_data(unsigned char);
    void lcdcmd(unsigned char);
    void lcddata(unsigned char);
    void Delay_ms(unsigned int msec) ;
     
    void main()
    {
    unsigned char data0[]=”rocks”;
    unsigned int i=0;
    lcdport=0;
     
    lcd_ini();
    while(data0!=’’)
    {
    dis_data(data0);
    Delay_ms(20);
    i++;
    }
    }
    void lcd_ini()                    
    {
    dis_cmd(0x02);
    dis_cmd(0x28);
    dis_cmd(0x0C);
    dis_cmd(0x06);
    dis_cmd(0x80);
    }
     
    void dis_cmd(unsigned char cmd_value)
    {
    unsigned char cmd_value1;
    cmd_value1 = (cmd_value & 0xF0);
    lcdcmd(cmd_value1);
    cmd_value1 = ((cmd_value<<4) & 0xF0);
    lcdcmd(cmd_value1);
    }
     
     
    void dis_data(unsigned char data_value)
    {
    unsigned char data_value1;
    data_value1=(data_value&0xF0);
    lcddata(data_value1);
    data_value1=((data_value<<4)&0xF0);
    lcddata(data_value1);
    }
     
    void lcdcmd(unsigned char cmdout)
    {
    lcdport=cmdout;
    rs=0;
    rw=0;
    en=1;
    Delay_ms(10);
    en=0;
    }
     
    void lcddata(unsigned char dataout)
    {
    lcdport=dataout;
    rs=1;
    rw=0;
    en=1;
    Delay_ms(10);
    en=0;
    }
      void Delay_ms(unsigned int msec) 
    {
    int i,j ;
    for(i=0;i<msec;i++)
      for(j=0;j<1100;j++);
      }
    March 6, 2013 at 5:04 am #9256
    arpan jain
    Participant

    How to interface keyboard with 8051
    Can u please provide the code for the same

    March 6, 2013 at 6:56 am #9257
    umar farrok
    Participant

    why you are trying with 4 bit better you try with 8 bit temperature sensor lm 35 temp range starts from -50 to 150 degree so assign it with 8 bit character value using 16×2 lcd 

     

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

RSS Recent Posts

  • Unknown, to me, electric motor fitting November 13, 2025
  • Can a small solar panel safely trickle-charge old NiMH AA batteries? November 13, 2025
  • KiCad custom symbol definition correct approach November 13, 2025
  • Measuring controller current output with a meter November 13, 2025
  • restarting this Christmas project November 12, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 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