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 / Not getting exaclty what i need on LCD

Not getting exaclty what i need on LCD

|

Microcontroller › AVR › Not getting exaclty what i need on LCD

  • This topic has 2 replies, 2 voices, and was last updated 14 years, 2 months ago by Sajan.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • February 9, 2012 at 10:31 am #1667
    Sajan
    Participant

    i am working on LCD interfacing using atmega16.. and my LCD is JHD162A.. i started with single letter ‘S’ and my code was working.. but in such cases it is not displaying the exact word what i need to be on lcd.. what i mean is if i will try with ” HELLO SAJAN ” , it is showing something like this.. ” IEMMO!SAKAO ” !!??! can anybody help me what is the mistake and why it is happening like this..
     

    my code is shown below..

     

    #include <avr/io.h>
    #define F_CPU 16000000L
    #include <util/delay.h>
     
    #define LCD_DATA PORTB // LCD data port
    #define ctrl PORTD
    #define en PD6 // enable signal
    #define rw PD5 // read/write signal
    #define rs PD4 // register select signal

    void LCD_cmd(unsigned char cmd);
    void init_LCD(void);
    void LCD_write(unsigned char);

     

    int main()
    {
        DDRB = 0xff; // making LCD_DATA port as output port
        DDRD = 0xf0; // making signal as out put
        init_LCD(); // initialization of LCD
        _delay_ms(50); // delay of 50 milli seconds
        LCD_write(‘H’); // call a function to write H on LCD
        LCD_write(‘E’); // call a function to write E on LCD
        LCD_write(‘L’); // call a function to write L on LCD
        LCD_write(‘L’); // call a function to write L on LCD
        LCD_write(‘O’); // call a function to write 0 on LCD
        LCD_write(‘ ‘);
        LCD_write(‘S’); // call a function to write S on LCD
        LCD_write(‘A’); // call a function to write A on LCD
        LCD_write(‘J’); // call a function to write J on LCD
        LCD_write(‘A’); // call a function to write A on LCD
        LCD_write(‘N’); // call a function to write N on LCD
        while (1);
        return 0;
    }

     

    void LCD_write(unsigned char data)
    {
        LCD_DATA = data;
        
        ctrl = (1 << rs)|(0 << rw)|(1 << en); // RW as LOW and RS, EN as HIGH
        _delay_ms(5);
        ctrl = (1 << rs)|(0 << rw)|(0 << en); // EN and RW as LOW and RS HIGH
        _delay_ms(5); // delay to get things executed
        return ;
    }

     

    void LCD_cmd(unsigned char cmd)
    {
        LCD_DATA=cmd;
        ctrl =(0 << rs)|(0 << rw)|(1 << en); // RS and RW as LOW and EN as HIGH
        _delay_ms(5);
        ctrl =(0 << rs)|(0 << rw)|(0 << en); // RS, RW , LOW and EN as LOW
        _delay_ms(5);
        return;
    }

     

    void init_LCD(void)
    {
        LCD_cmd(0x38); // initialization of 16X2 LCD in 8bit mode
        _delay_ms(5);
     
        LCD_cmd(0x01); // clear LCD
        _delay_ms(5);
     
        LCD_cmd(0x0E); // cursor ON
        _delay_ms(5);
     
        LCD_cmd(0x80); // —8 go to first line and –0 is for 0th position
        _delay_ms(5);

        return;
    }

    March 2, 2012 at 1:43 pm #7210
    shreenu
    Participant

    set the internal pullup resistor:DDRB = 0xff; // making LCD_DATA port as output port
        DDRD = 0xf0; // making signal as out put and use  PORTB =0xFF, and PORTC =0xFF;

    March 3, 2012 at 12:39 pm #7215
    Sajan
    Participant

    thank you for the reply..
    but still result is same.. there’s nothing change in it.. :(

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

RSS Recent Posts

  • 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
  • Smart Buoy project 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