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 / AT89C51 DS1307 ]- LCD only shows bars (updated : schematic and Photo.

AT89C51 DS1307 ]- LCD only shows bars (updated : schematic and Photo.

|

Microcontroller › 8051 › AT89C51 DS1307 ]- LCD only shows bars (updated : schematic and Photo.

  • This topic has 12 replies, 7 voices, and was last updated 12 years ago by Anonymous.
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • April 19, 2013 at 6:12 pm #4806
    Rohan Thacker
    Participant

    Hey this is my first post on EG, hope to be apart of the community for a long time, moving forward. Im trying to build a simple circut using an AT89C51 with a DS1307 interfaced with a 16×2 LCD. I know there are numerous projects other and thats the reason why im repeating it, to learn. The problem is now when i flash my code to the uC and connect it into the circut the lcd just displays bars. I’ve tried with alot of different programs avaliable online. Due to my lack of experience i have no clue how to debug this issue. I’ve also tried a smiple program to check the LCD and thats not working to a simple Hello World program fails to display. I’ve attached a schematic of my breadboard circuit and a picture of the whole issue.

     

    April 20, 2013 at 4:47 pm #9545
    AJISH ALFRED
    Participant

    Hi Rohan,

    Introduce a 1K resistor in series with the 15th or 16th pin.

    Most importantly make sure that your code is running on the microcontroller by trying to blink an led along with the current code.

    April 21, 2013 at 6:30 pm #9547
    Rohan Thacker
    Participant

    I’ve got an led blinking off pin 1. I also tried this with a different LCD screen (same 16×2) and the only difference was that the older one showed 4 bars instead of 6. I also put in a different 89c51uC, still no different.

     

    I’ve checked the schematic with the various circuts form a google search and the wiring seem to be correct, can you guys verify that? I’m not really if my reset (pin9) is connected correct.

     

    This is the code i use

    <code>

     

    #include<reg51.h>
     
    //Function declarations
    void cct_init(void);
    void delay(int);
    void lcdinit(void);
    void writecmd(int);
    void writedata(char);
    void ReturnHome(void);
     
    //*******************
    //Pin description
    /*
    P2.4 to P2.7 is data bus
    P1.0 is RS
    P1.1 is E
    */
    //********************
     
    // Defines Pins
    sbit RS = P1^0;
    sbit E  = P1^1;
     
    // ***********************************************************
    // Main program
    //
    void main(void)
    {
       cct_init();                                     //Make all ports zero
       
       lcdinit();                                      //Initilize LCD
     
       writedata(‘T’);                                 //write
       writedata(‘H’);                                 //write
       writedata(‘A’);                                 //write
       writedata(‘C’);                                 //write
       writedata(‘K’);                                 //write
       writedata(‘ ‘);                                 //write
       writedata(‘E’);                                 //write
       writedata(‘l’);                                 //write
       writedata(‘e’);                                 //write
       writedata(‘c’);                                 //write
       writedata(‘t’);                                 //write
       writedata(‘r’);                                 //write
     
       ReturnHome();                                   //Return to 0 position
     
    while(1)
    {
    }
     
    }
     
     
    void cct_init(void)
    {
    P0 = 0x00;   //not used 
    P1 = 0x00;   //not used 
    P2 = 0x00;   //used as data port
    P3 = 0x00;   //used for generating E and RS
    }
     
    void delay(int a)
    {
       int i;
       for(i=0;i<a;i++);   //null statement
    }
     
    void writedata(char t)
    {
       RS = 1;             // This is data
     
       P2 &= 0x0F;   // Make P2.4 to P2.7 zero
       P2 |= (t&0xF0);     // Write Upper nibble of data
     
       E  = 1;             // => E = 1
       delay(150);
       E  = 0;             // => E = 0
       delay(150);
     
       P2 &= 0x0F;   // Make P2.4 to P2.7 zero
       P2 |= ((t<<4)&0xF0);// Write Lower nibble of data
     
       E  = 1;             // => E = 1
       delay(150);
       E  = 0;             // => E = 0
       delay(150);
    }
     
     
    void writecmd(int z)
    {
       RS = 0;             // This is command
     
       P2 &= 0x0F;   // Make P2.4 to P2.7 zero
       P2 |= (z&0xF0);     // Write Upper nibble of data
     
       E  = 1;             // => E = 1
       delay(150);
       E  = 0;             // => E = 0
       delay(150);
     
       P2 &= 0x0F;   // Make P2.4 to P2.7 zero
       P2 |= ((z<<4)&0xF0);// Write Lower nibble of data
     
       E  = 1;             // => E = 1
       delay(150);
       E  = 0;             // => E = 0
       delay(150);
    }
     
    void lcdinit(void)
    {
      ///////////// Reset process from datasheet /////////
         delay(15000);
     
    P2 &= 0x0F;   // Make P2.4 to P2.7 zero
    P2 |= (0x30&0xF0);    // Write 0x3
     
    E  = 1;               // => E = 1
    delay(150);
    E  = 0;               // => E = 0
    delay(150);
     
         delay(4500);
     
    P2 &= 0x0F;   // Make P2.4 to P2.7 zero
    P2 |= (0x30&0xF0);    // Write 0x3
     
    E  = 1;               // => E = 1
    delay(150);
    E  = 0;               // => E = 0
    delay(150);
     
         delay(300);
     
    P2 &= 0x0F;   // Make P2.4 to P2.7 zero
    P2 |= (0x30&0xF0);    // Write 0x3
     
    E  = 1;               // => E = 1
    delay(150);
    E  = 0;               // => E = 0
    delay(150);
     
         delay(650);
     
    P2 &= 0x0F;   // Make P2.4 to P2.7 zero
    P2 |= (0x20&0xF0);    // Write 0x2
     
    E  = 1;               // => E = 1
    delay(150);
    E  = 0;               // => E = 0
    delay(150);
     
    delay(650);
     
      /////////////////////////////////////////////////////
       writecmd(0x28);    //function set
       writecmd(0x0c);    //display on,cursor off,blink off
       writecmd(0x01);    //clear display
       writecmd(0x06);    //entry mode, set increment
    }
     
    void ReturnHome(void)     //Return to 0 location
    {
      writecmd(0x02);
        delay(1500);
    }
    </code>
    Looks incomplete. is it?
    April 22, 2013 at 9:30 am #9560
    AJISH ALFRED
    Participant

    Hi,

    Keep the connection to the reset pin same for all your projects as you have connected for the led blinking.

    April 22, 2013 at 9:32 am #9561
    AJISH ALFRED
    Participant

    Why do you think the code is incomplete??

    April 22, 2013 at 11:08 am #9566
    Rohan Thacker
    Participant

    Yes the reset pin is the same on all my projects. I’ve also tired the EG code for displaying A on the LCD and that isnt working too. The  16×2 displays boxes on the first line and nothing on the second. Then I tried replacing the cap on the circut, the crystal and the power wires along with programming the uC again  but that didnt work either. So then i checked if all the pins on the LCD were receiving electricty so with the help of an Led i check each pin, all good. So now i have no clue what the problem is, I’ve connected it in 8 bit and 4 bit and tried all sorts of code.

     

    April 23, 2013 at 6:20 am #9573
    alekhya
    Participant

    sir i kept my query separately but u didnt answ to my query till now…………sad

    April 25, 2013 at 2:59 pm #9584
    vishwas
    Participant

    hey i am also trying to interface 8051 microcontroller with a 16×2 LCD display but i dont know how to flash a C code into microcontroller.Please help me.

     

    June 25, 2013 at 10:06 am #10024
    umair
    Participant

    Hello Rohan i can not understand your problem completely but i think u want to make project with 8051 and LCD so dont worry i shall try my best to help u.i hv uploaded my project videos and C codes on 4 shared .com u can make free account and then u can download free still if u need my help u can send me mail on [email protected] My project and video link is http://www.4shared.com/rar/F3bhcolV/at89s52_programmer_and_test_bo.html u can find other projects too.

    t care bye

    June 25, 2013 at 10:33 am #10025
    umair
    Participant

    hello rohan i hv given my comments but i dont know why that are coming here may be it takes time to come here.any way i can help u for ur 8051 and LCD project u can open this link here i hv uploaded my projects videos and code u can dounload free from here also u can send me mail [email protected]. its 4shared.com u make free account here then dounload my projects.

    its link for my 8051 test board project on this board i hv LCD,ADC,ISP Programmer,LEDs and more detail th will help u.

    http://www.4shared.com/rar/F3bhcolV/at89s52_programmer_and_test_bo.html .

    t cre bye

    June 25, 2013 at 10:37 am #10026
    umair
    Participant

    hello rohan i hv given my comments but i dont know why that are coming here may be it takes time to come here.any way i can help u for ur 8051 and LCD project u can open this link here i hv uploaded my projects videos and code u can dounload free from here also u can send me mail umair_saeed65 on yahoo.com. its 4shared.com u make free account here then dounload my projects.

    its link for my 8051 test board project on this board i hv LCD,ADC,ISP Programmer,LEDs and more detail th will help u.

    send me mail then i shall send u link as if i paste link here then file is not updating .

    t cre bye

    June 25, 2013 at 11:30 am #10027
    Ajay Maity
    Participant

    Hello Rohan Thacker,

         

              This post is two months old. Have you rectified your problem? Are you able to get characters on LCD screen? What value of resistor (R4) have you connected at pin no. 3? I recommend instead of resistor, use a potentiometer. After switching on the system and burning the code, try varying the potentiometer shaft until the characters are clearly displayed on the screen. This potentiometer act as a control for LCD contrast. It gives flexibility to the user to vary the brightness from displaying nothing to displaying block patterns (which is exactly what is getting displayed on your screen).

              Try this method, and reply if it works, and also if it doesn’t. I’ll think of something else.

    Regards,

    Ajay Maity.

    June 26, 2013 at 1:32 pm #10041
    Anonymous
    Guest

    hello rohan my friend i hv uploded my project videos link on utube write AT89S52 TEST BOARD on utube then u can see the complete circuit from utube page u can go on 4shared site link downlod my test board project files that are in winrar parts downlod all see complete circuit board video also i hv given C codes.

    there u can also find my other projects.

    best of luck

    t care

    bye

  • 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

  • Adhesive Defibrillator Pad Cable June 25, 2025
  • Epson crystal oscillators June 25, 2025
  • Simple LED Analog Clock Idea June 24, 2025
  • Fun with AI and swordfish basic June 24, 2025
  • Microinverters and storeage batteries? June 23, 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