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
You are here: Home / Topics / How to Interface 4-bit & 8-bit Lcd Step by Step

How to Interface 4-bit & 8-bit Lcd Step by Step

|

Microcontroller › AVR › How to Interface 4-bit & 8-bit Lcd Step by Step

  • This topic has 2 replies, 3 voices, and was last updated 5 years ago by Ashutosh Bhatt.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • July 28, 2017 at 6:08 pm #4682
    Faroogh
    Participant

    Hi Every one Please tell me How to interface 4-bit Lcd Step by Step

     

    this My Code for Lcd Initialization

    Create a Heade File and past the code in it it Will Work

     

    **************************************************************************************************************************************************

    #ifndef LCD_H
    #define LCD_H
     
     
    #include <avr/io.h>
    #define F_CPU 1000000UL
    #include <util/delay.h>
     
    char colmn[2]={0x80,0xC0};
     
    #define LcdData PORTB
    #define LcdDataDDR DDRB
    #define LcdCtrlDDR DDRD
    #define LcdCtrl PORTD
    #define RS PD0
    #define RW PD1
    #define E PD2
     
     
     
     
     
    void Lcd_Ini(void);
    void SendData(unsigned char data);
    void LcdString(char *str);
    void SendCmd(unsigned char cmd);
    void SetCursor(uint8_t x,uint8_t y);
     
     
    void Lcd_Ini()
    {
    SendCmd(0x38);
    _delay_us(50);
    SendCmd(0x01);
    _delay_ms(1);
    SendCmd(0x0E);
    _delay_us(50);
    SendCmd(0x80);
    _delay_us(50);
    }
    void SendData(unsigned char data)
    {
     
    LcdData = data;
    LcdCtrl = (1<<RS)|(0<<RW)|(1<<E);
    _delay_us(50);
    LcdCtrl = (1<<RS)|(0<<RW)|(0<<E);
    return;
     
    }
    void SendCmd(unsigned char cmd)
    {
    LcdData = cmd;
    LcdCtrl = (0<<RS)|(0<<RW)|(1<<E);
    _delay_us(1);
    LcdCtrl = (0<<RS)|(0<<RW)|(0<<E);
    _delay_ms(1);
    return;
     
    }
    void LcdString(char *str)
    {
    int i=0;
    while(str!='')
    {
    SendData(str);
    i++;
    }
    }
    void SetCursor(uint8_t x,uint8_t y)
    {
    SendCmd(colmn[y]+x);
    }
     
     
     
     
    #endif
     
    August 5, 2017 at 4:43 am #14643
    Hari Prasaath K
    Participant

    Explain what problem you are facing. Its not clear whether you are asking doubt or providing solution.

    August 5, 2017 at 7:15 am #14648
    Ashutosh Bhatt
    Participant

    4 bit LCD mode
    Divide 8 bit data in to two 4 bit nibbles using masking
    First send higher nibble
    Then send lower nibble
    Every time for sending 1 byte. You hv to send two nibbles

  • 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

  • Can I use an SPDT 5 wire Relay in reverse? August 9, 2022
  • Basic questions about MOSFETS, Gate Drivers and Diodes August 9, 2022
  • LTSpice DC-AC August 9, 2022
  • Circuit Problem August 8, 2022
  • Google translate suggest "device sheet" or "apparatus sheet" but that cannot be ? August 8, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

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