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 / Lcd interfacing with Attiny Microcontroller

Lcd interfacing with Attiny Microcontroller

|

Microcontroller › 8051 › Lcd interfacing with Attiny Microcontroller

  • This topic has 3 replies, 2 voices, and was last updated 14 years, 9 months ago by Anonymous.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • August 30, 2010 at 8:40 am #4423
    Chetan Patil
    Participant

    Hi all. This is my first post an im beginner.

    Im interfacing Attiny 2313 with 16*2 lcd.following is the code.

    i have used PORTD6,PORTAO,PORTA1 pins for controlling lcd.progarm displays A to Z.here is code its executed succesfully but nothing is displayed on lcd.

    i also wanted to know if we can use PORTD and PORTA as input or output lines…please help.Waiting for replies…thanks in advance

    #include

    #define F_CPU 1000000UL

    #include

    #include

    #define LCD_data PORTB

    #define LCD_D7 PORTB

    #define LCD_rs PORTA

    #define LCD_rw PORTA

    #define LCD_en PORTD

    #define HIGH LCD_en | (0x01 << 5)

    #define LOW LCD_en & ~(0x01 << 5)

    void LCD_busy()

    {

    LCD_D7 = LCD_D7 | (0x01 << 7); //Make D7th bit of LCD as i/p

    LCD_en = LCD_en | (0x01 << 5); //Make port pin as o/p

    LCD_rs = LCD_rs & ~(0x01 << 0); //Selected command register

    LCD_rw = LCD_rw | (0x01 << 1); //We are reading

    while(LCD_D7 & (0x01 << 7))

    { //read busy flag again and again till it becomes 0

    LCD_en = LOW; //Enable H->L

    LCD_en = HIGH;

    }

    }

    void LCD_command(unsigned char var)

    {

    LCD_data = var; //Function set: 2 Line, 8-bit, 5×7 dots

    LCD_rs = LCD_rs & ~(0x01 << 0); //Selected command register

    LCD_rw = LCD_rw & ~(0x01 << 1); //We are writing in instruction register

    LCD_en = HIGH; //Enable H->L

    LCD_en = LOW;

    LCD_busy(); //Wait for LCD to process the command

    } // Using the above function is really simple

    // var will carry the command for LCD

    // e.g. // // LCD_command(0x01); which is used to clear lcd

    void LCD_init()

    {

    LCD_command(0x38); //Function set: 2 Line, 8-bit, 5×7 dots

    LCD_busy(); //Wait for LCD to process the command

    LCD_command(0x0F); //Display on, Curson blinking command

    LCD_busy(); //Wait for LCD to process the command

    LCD_command(0x01); //Clear LCD

    LCD_busy(); //Wait for LCD to process the command

    LCD_command(0x06); //Entry mode, auto increment with no shift LCD_busy();

    }

    void LCD_clear()

    {

    LCD_command(0x01);

    LCD_busy();

    }

    void LCD_senddata(unsigned char var)

    {

    LCD_data = var; //Function set: 2 Line, 8-bit, 5×7 dots

    LCD_rs = LCD_rs | (0x01 << 0); //Selected data register

    LCD_rw = LCD_rw & ~(0x01 << 1); //We are writing

    LCD_en = HIGH; //Enable H->L

    LCD_en = LOW;

    LCD_busy(); //Wait for LCD to process the command

    } // Using the above function is really simple

    // we should pass the character to display as argument to function // e.g. // LCD_senddata(‘A’);

    main()

    {

    DDRB = 0xff;

    DDRA = 0x03;

    DDRD = 0x40;

    LCD_init();

    unsigned char ch = ‘A’;

    while(1)

    {

    if(ch == ‘Z’)

    { ch = ‘A’;

    LCD_clear();

    }

    LCD_senddata(‘A’); ch++; _delay_ms(1000);

    }

    }

    August 31, 2010 at 6:57 am #5028
    Anonymous
    Guest

    first of all this code cannot display A to Z.. bcoz in main() u have given:
    LCD_senddata(‘A’)

    so it will always display ‘A’.. u shud change it to: LCD_senddata(ch)

    The possible problems may be:
    a. ur connections may be improper
    b. u might have connected the LCD data pins to ATtiny pins in d wrong order

    August 31, 2010 at 9:34 am #5030
    Chetan Patil
    Participant

    hi thanks Nikhil atlast i got a reply from someone….i have grounded contrast control pin is thatt ok or should i connect potentiometer to it??
    i have connected Do pin of lcd to portb0 an D1 to portb1 an so on ,i hope its correct order.

    August 31, 2010 at 1:38 pm #5031
    Anonymous
    Guest

    the order of connection is ok.. connect a preset/pot to the contrast pin of LCD.

    Please check that : R/W=0 when we write to LCD
    Also check for RS signals.

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

RSS Recent Posts

  • Siemens large industrial PLC parts June 15, 2025
  • Parts required for a personal project June 15, 2025
  • Cant log in to Easy PC forum June 15, 2025
  • Failure of polypropylene motor-run capacitors June 15, 2025
  • Wideband matching an electrically short bowtie antenna; 50 ohm, 434 MHz June 15, 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