Microcontroller › 8051 › I need help to understand programe in digital clock using LCD.
- This topic has 4 replies, 3 voices, and was last updated 12 years ago by Amit Kumar.
May 13, 2011 at 12:09 pm #929Amit KumarParticipant
lcd_data_int(int time_val) // Function to send number on LCD
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.
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 #6191dagakshayParticipant
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 positionMay 14, 2011 at 3:33 am #6192dagakshayParticipant
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
and 56 is ascii code for 7…
i hope you understoodMay 16, 2011 at 2:24 am #6208romel emperadoParticipant
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 #6231Amit KumarParticipant
I thanks both of you. you helped me to understand.
- You must be logged in to reply to this topic.