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 / problem regarding interfacing LCD using ATMEGA16 code by CHINMAY CHINARA

problem regarding interfacing LCD using ATMEGA16 code by CHINMAY CHINARA

|

Microcontroller › AVR › problem regarding interfacing LCD using ATMEGA16 code by CHINMAY CHINARA

  • This topic has 4 replies, 4 voices, and was last updated 14 years, 5 months ago by Sagar.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • July 11, 2011 at 5:45 am #1067
    query
    Participant

    I am using the JHD162A LCD and based on the tutorial code.The connections are made as per the tutorial circuit diagram. But instead of showing an ‘A’ on the screen what I see is the backlit display is on and the first line of the screen is filled with black squares. Even if I increase or decrease the contrast pot only the black sqares become dark or light and no other output is obtained. Kindly help me out with it.

    July 23, 2011 at 6:15 am #6503
    dagakshay
    Participant

    this sounds some loose connection problem…

    December 5, 2011 at 5:10 pm #6910
    Tuhin
    Participant

    You have made a worng connection. Just see the back sibe of LCD and conform which pin is no1. and so on. Then connect it. I myself suffered from this problem.I’m giving you the pin configration of LCD you connect it as per your requirment.

     

    1.GND

    2.VDD(5V or 3V)

    3.V0(Contrast adjustment)

    4.RS

    5.R/W

    6.EN

    7.DB0

    8.DB1

       :

       :

       :

    14.DB7

    15.LED+(~ 4.2V)

    16.LED-(GND)

                Just see the backside of lcd and make sure  your connection is right or not.  

    December 6, 2011 at 9:40 am #6912
    Sagar
    Participant

    m having same problem with JHD162A ATmega16

    heres the code…

     

    //#define F_CPU 16000000

    #include <avr/io.h>
    //#include <util/delay.h>

    #define lcd_data PORTB

    /*

    PD.0=rs
    PD.1=rw
    PD.2=en

    */

    void lcdbusy() //function to monitor d7th bit (busy flag)
    {
        DDRB=0x7f;// this will make msb of portb to input

        PORTD=0xfe;// rs=0 rw=1 en=1, rw=1->read from lcd

        while(PINB>>7) //move the msb to lsb
        {

            PORTD |=0x04; //en-> from low to high
            PORTD &=0xfb; //en-> from high to low
        }

        DDRB=0xff;//make PORTB for output

    }

    void initlcd()
    {
        DDRD=0xff; //PORTD as output
        DDRB=0xff; //portb as output
        
        lcd_data=0x38; //8 bit,5×7 dots
        PORTD=0xfc; //rs=0 rw=0 en=1, 0xfc where c=1100
        PORTD=0xf8; //rs=0 rw=0 en=0, 0xf8 where 8=1000, frm en->high to low

        lcdbusy(); // w8 b4 executing next command

        lcd_data=0x0f; //cursor blinking display on
        PORTD=0xfc;
        PORTD=0xf8;

        lcd_data=0x01; // clear lcd
        PORTD=0xfc;
        PORTD=0xf8;

        lcdbusy();

        lcd_data=0x06; //entry mode
        PORTD=0xfc;
        PORTD=0xf8;

        lcdbusy();
    }

    void lcdcmd(unsigned char ch)
    {
        lcd_data=ch;
        PORTD=0xfc;
        PORTD=0xf8;

        lcdbusy();
    }

    void lcdchar(unsigned char ch)
    {
        lcd_data=ch;
        PORTD=0xfd; // 0xfd where d=1101 rs=w rw=0 en=1
        PORTD=0xf9; //9=1001 rs=1 rw=0 en=0, en-> from high to low
        lcdbusy();
    }

    void lcdstring(char *str)
    {
        while(*str)
        {
            lcdchar(*str);
            str++;
        }
    }

    int main()
    {
        initlcd();
        lcdcmd(0x80);// move cursor to 1st line 1st column
        lcdstring(“Welcome ATmega16 !”);

        while(1);

        return 0;

    }

     

     

    m i missing something ?

    December 6, 2011 at 1:34 pm #6913
    Sagar
    Participant

    hey guys solved my problem…. !

     

    this is wat i did.

     

    added little delay betwn two instruction of enable pin.

     

    @query :  add _delay_ms(1); after each high to low pulse for enable pin. :)

    surely this will work for you.

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

RSS Recent Posts

  • Phone Charger 5v to 12v May 17, 2026
  • reviving old swordfish program but? May 17, 2026
  • Assistance locating a 'trail' camera gadget, please ? May 16, 2026
  • Analog multiplexer has gone obselete May 16, 2026
  • Difference between TTL, RS232 and RS485 May 16, 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