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 / plz tell the problem in this lcd program.it is not showing the output

plz tell the problem in this lcd program.it is not showing the output

|

Microcontroller › 8051 › plz tell the problem in this lcd program.it is not showing the output

  • This topic has 7 replies, 7 voices, and was last updated 12 years ago by ddrk.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • June 19, 2013 at 2:51 pm #2492
    gopal
    Participant
    #include<reg51rd2.h>
    #define command P1
    #define data P2
    #define rs P1_0
    #define rw P1_1
    #define e P1_2
    void delay_ms(unsigned int m)
    {
    int i,j;
    for(i=0;i<m;i++);
    for(j=0;j<233;j++);
    }
    void lcd_command(unsigned char value)
    {
    P1=value;
    rs=0;
    rw=0;
    e=1;
    delay_ms(100);
    e=0;
    }
    void lcd_data(unsigned char value)
    {
    P2=value;
    rs=1;
    rw=0;
    e=1;
    delay_ms(100);
    e=0;
    }
    void init()
    {
    lcd_command(0x38);
    lcd_command(0x0e);
    lcd_command(0x06);
    }
    void main()
    {
    init();
    lcd_command(0x80);
    lcd_data(‘s’);
    delay_ms(10);
    lcd_data(‘i’);
    delay_ms(10);
    lcd_data(‘r’);
    delay_ms(10);
    }
    June 19, 2013 at 3:47 pm #9990
    GANESHAPERUMAL
    Participant
    please use this code and reply to this mailid the code is correct or wrong and one more thing pl send correct microcontroller no .ex p89v51rd2 like that . 
     
    [email protected]
      
     
    if u have any question pl contact me 
      +919940840471  after 6 pm
     
     
     
    #include<reg51.h>
    #define command P1
    #define data P2
    sbit rs = P1^0;
    sbit rw = P1^1;
    sbit e = P1^2;
     
    void delay_ms(unsigned int m)
    {
    int i,j;
    for(i=0;i<m;i++);
    for(j=0;j<233;j++);
    }
    void lcd_command(unsigned char value)
    {
    P1=value;
    rs=0;
    rw=0;
    e=1;
    delay_ms(100);
    e=0;
    }
    void lcd_data(unsigned char value)
    {
    P2=value;
    rs=1;
    rw=0;
    e=1;
    delay_ms(100);
    e=0;
    }
    void init()
    {
    lcd_command(0x38);
    lcd_command(0x0e);
    lcd_command(0x06);
    }
    void main()
    {
    init();
    lcd_command(0x80);
    lcd_data(‘s’);
    delay_ms(10);
    lcd_data(‘i’);
    delay_ms(10);
    lcd_data(‘r’);
    delay_ms(10);
    }
    June 19, 2013 at 4:59 pm #9992
    gopal
    Participant

    microcontroller no’s at89c051

    June 20, 2013 at 2:44 am #9994
    ANJUSHA
    Participant

     

     

     

     

     you have taken port1 for passing commands

    and port2 for data but for lcd we consider 8/4 data pins …then how can you make use same 8 pins for port1 and for port2..so consider any one port.

     

    so take port2/port1.use command 0x01 to clear the display before 0x80 and b/w every command in intializing lcd use delay;

     

     

    June 20, 2013 at 8:03 am #9998
    manohar
    Participant
    //use this code and connect the pins correctly data port is P1 here control pins P2.0 P2.1,P.2
     
    #include<reg51.h>
    #define rs  P2^0     ///edited
    #define rw  P2^1   //edited
    #define e  P2^2     //edited
     
    void delay_ms(unsigned int m)
    {
    int i,j;
    for(i=0;i<m;i++);
    for(j=0;j<233;j++);
    }
     
    void lcd_command(unsigned char value)
    {
    P1=value;
    rs=0;
    rw=0;
    e=1;
    delay_ms(100);
    e=0;
    }
    void lcd_data(unsigned char value)
    {
    P1=value;///edited
    rs=1;
    rw=0;
    e=1;
    delay_ms(100);
    e=0;
    }
    void init()
    {
    lcd_command(0x38);
    lcd_command(0x0e);
    lcd_command(0x06);
    }
    void main()
    {
    init();
    lcd_command(0x80);
    lcd_data(‘s’);
    delay_ms(10);
    lcd_data(‘i’);
    delay_ms(10);
    lcd_data(‘r’);
    delay_ms(10);
    }
    June 20, 2013 at 2:48 pm #9999
    Praneeth
    Participant
    #include<reg51.h>
     
    #define rs P1_0
    #define rw P1_1
    #define e P1_2
    void delay_ms(unsigned int m)
    {
    int i,j;
    for(i=0;i<m;i++);
    for(j=0;j<233;j++);
    }
    void lcd_command(unsigned char value)
    {
    P1=value;
    rs=0;
    rw=0;
    e=1;
    delay_ms(100);
    e=0;
    }
    void lcd_data(unsigned char value)
    {
    P2=value;
    rs=1;
    rw=0;
    e=1;
    delay_ms(100);
    e=0;
    }
    void init()
    {
    lcd_command(0x38);
    lcd_command(0x0e);
    lcd_command(0x06);
    lcd_command(0x01);
     
    }
    void main()
    {
    init();
    lcd_command(0x80);
    lcd_data(‘s’);
    delay_ms(10);
    lcd_data(‘i’);
    delay_ms(10);
    lcd_data(‘r’);
    delay_ms(10);
    }
    June 28, 2013 at 4:17 am #10047
    AJISH ALFRED
    Participant

    Hi all,

     

    The issues with the LCD are already discussed so many times in this forum. You can search the previous discussions regarding the LCD in this forum and I’m sure that it will help you.

    Normally the problems occurs due to:

    -wrong hardware connections

    -loose contact of any data or control lines

    -short circuit of the data or control lines

    -port not made as output

    -wrong or incomplete initializing commands

    -wrong method of activating the enable pin

    -insufficient delay 

     

    Check all of them.

    June 28, 2013 at 4:51 am #10050
    ddrk
    Participant

    just change the this 

     

    connect your lcd data pins to P2

     

    void lcd_command(unsigned char value)
    {
    P2=value;
    rs=0;
    rw=0;
    e=1;
    delay_ms(100);
    e=0;
    }
    void lcd_data(unsigned char value)
    {
    P2=value;
    rs=1;
    rw=0;
    e=1;
    delay_ms(100);
    e=0;
    }
     
    or 
     
    if you use this connect ur lcd data pins to P1
     
    void lcd_command(unsigned char value)
    {
    P1=value;
    rs=0;
    rw=0;
    e=1;
    delay_ms(100);
    e=0;
    }
    void lcd_data(unsigned char value)
    {
    P1=value;
    rs=1;
    rw=0;
    e=1;
    delay_ms(100);
    e=0;
    }
  • Author
    Posts
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Fun with AI and swordfish basic July 19, 2025
  • using a RTC in SF basic July 19, 2025
  • Does US electric code allow branching ? July 19, 2025
  • Faulty heat air gun (dc motor) - problem to locate fault due to Intermittent fault July 19, 2025
  • Sump pit water alarm - Kicad 9 July 19, 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