Microcontroller › 8051 › I need help to understand programe in digital clock using LCD. › you need ascii character to
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.. ")