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 / I need help to understand programe in digital clock using LCD.

I need help to understand programe in digital clock using LCD.

|

Microcontroller › 8051 › I need help to understand programe in digital clock using LCD.

  • This topic has 4 replies, 3 voices, and was last updated 14 years, 2 months ago by Amit Kumar.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • May 13, 2011 at 12:09 pm #929
    Amit Kumar
    Participant
    lcd_data_int(int time_val)   // Function to send number on LCD
    {
    int int_amt;
    int_amt=time_val/10;
    lcd_data(int_amt+48);
    int_amt=time_val%10;
    lcd_data(int_amt+48);
    }

    I am understanding programe that is written  for LCD digital clock. I did not understand this function. Could anyone help me to understand what is TIME VALUE and why it is divided by 10. What is int_amt & why 48 is added in it.

     

    lcd_cmd(0xc3);

    lcd_cmd(0xc6);

    There are two commands for LCD in the programe. Could anyone help me what these commands meant for.

    May 14, 2011 at 3:27 am #6191
    dagakshay
    Participant

    hello amit kumar,

    the quantity you want to display on LCD is in int formate LCD display in ascii formate.. so you need to send ascii code of repective number or alphabet to display.. if you want to display A on LCD thenyou need to send 65 to LCD…

     

    in your LCD 16×2

    there are 2 lines16 character in each lines space available on your LCD… to jump in first line you need to send 0x80 in command formate.. in first line you can move as 0x81, 0x82, 0x83…..0x8f

    for second line it starts from 0xc0

    so 0xc3 means second line 4 position

    0xc6= 2 line 7th position

    May 14, 2011 at 3:33 am #6192
    dagakshay
    Participant

    whn you display any number it shuld be one digit at a time sine ascii contains only 0 to 9 to display 123 you need to send 1  2 and the 3 seperatly and by adding 48 to that, it will get convert in ascii code

    as we want to display 7 we send

    lcd_data(7+48);

    and 56 is ascii code for 7…

    i hope you understood

     

    May 16, 2011 at 2:24 am #6208
    romel emperado
    Participant

     

    you need ascii character to display in LCD so here’s the trick of that program.

     

    example you want to display 23 in LCD then we will store that 23 in a variable

     

    int c = 23;

     

    c = c/10;   // c now is = 2 since we are deviding integer numbers.

     

    c= c+48;  // now we add 48 to convert it to ascii character and ready to display in LCD.. 2+48 =50. 50 is the ascii equivalent  of number 2..

     

    then do the same for the other number

     

    c = c%10;   // c now is e = 3 since we se modulo operation.

    c= c+48;  // now we add 48 to convert it to ascii character and ready to display in LCD.. 3+48 =51. 51 is the ascii equivalent  of number 3

     

    and after that operation you are ready to display 23 in the LCD.  :)

     

     

    lcd_cmd(0xc3); // this is simply for the location of the lcd


    if 0xCx meaning 2nd row and the value of x is anything not more than 16 since we have 2x16 LCD

    when we have 0x8x meaning 1st row and the value of x is lcd
    anything not more than 16 since we have 2x16



    i hope you got it.. ")

     

    May 16, 2011 at 10:06 am #6231
    Amit Kumar
    Participant

    I thanks both of you. you helped me to understand.

  • 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

  • I Wanna build a robot July 13, 2025
  • Wierd makita battery July 13, 2025
  • using a RTC in SF basic July 13, 2025
  • Is AI making embedded software developers more productive? July 13, 2025
  • ac current limiting July 13, 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