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 / Want Help about coding the 16*2 interfacing to lcd for sending the numeric data

Want Help about coding the 16*2 interfacing to lcd for sending the numeric data

|

Microcontroller › 8051 › Want Help about coding the 16*2 interfacing to lcd for sending the numeric data

  • This topic has 2 replies, 3 voices, and was last updated 10 years, 11 months ago by Ashutosh Bhatt.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • July 8, 2014 at 4:48 am #3139
    awais
    Participant

    This is code to send numeric data on 16*2 lcd using the 8051 plz explain it

    void lcd_data(unsigned int i)     //Function to send data on LCD
    { int p;
    int k=0;
    while(i>0)
    {
    num[k]=i%10;
    i=i/10;
    k++;
    }
    k--;
    for (p=k;p>=0;p--)
    {
    c=num[p]+48;
    lcd_data_pin = c;
    rw = 0;
    rs = 1;
    en = 1;
    delay(1);
    en = 0;
    }
    return;
    }

    July 8, 2014 at 5:07 am #11876
    AJISH ALFRED
    Participant

    Hi Awais,

    I can give you some clues regarding the logic used,

     

    These two lines are the key,

     num[k]=i%10;
    This will store the value in the unit place of 'i' to 'k' the variable in 'num'

    For example if i = 1234, the value of num [k] will be '4'.

    Since to diaplay a value like '4' in the lcd we need to convert it to its ascii value first, the following statement does the same,

    c=num[p]+48;

    Remember ’48’ is the ascii value of ‘0’. (zero) 

    July 8, 2014 at 8:25 am #11879
    Ashutosh Bhatt
    Participant

    to display anything on LCD first it must be converted into ASCII

    e.g. to display A you have to send its  ASCII value 40h

    to display a you have to send its ASCII value 63h

    to display any number 0 to 9 send 30h to 39h

    like wise

    the given function first saparate all the digits of any number (eg 254 = 2, 5, 4)

    then it converts all number into ASCII by adding 30h = 48 d

     

  • 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

  • IoT: Transforming Businesses with Digital Engineering June 23, 2025
  • PIC KIT 3 not able to program dsPIC June 23, 2025
  • Fun with AI and swordfish basic June 23, 2025
  • Is AI making embedded software developers more productive? June 23, 2025
  • Microinverters and storeage batteries? June 22, 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