Page 1 of 2
how to display a value in LCD

Posted:
Sat Dec 18, 2010 11:52 pm
by tst
I modified from cytron source code
For example,
unsigned int distance = 0;
SetCurXLCD(0);
distance = distance + 1; //for each loop
putrsXLCD(distance);
RESULT:
the LCD unable to display the proper value, it become unknown symbol.
If i use putcXLCD(distance) also cannot.
If i use putrsXLCD("1") then can show but this method not efficient cause i have a lot of value need to display using loop.
Question:
How to display the content inside of variable distance? for example 1, 2, 3...up to 100? (actually i would like to have decimal point for example 1.5, 2.0, 2.5...)
Can I to convert the value inside the variable of distance into STRING format so that i can display using putrsXLCD(distance)? But I duno how to convert. =.="
Thanks..
Re: how to display a value in LCD

Posted:
Mon Dec 20, 2010 8:03 pm
by yonghui
hi,
the LCD accept ascii characters and decode to the character according to the table in the datasheet,
when u send in numbers, it will treat it as ascii value, not the numeric value.
example:
if u wan to display 12
12/10=1;
offset +1 from the ascii table then send the ascii value of 1 to the LCD
12-10=2;
offset+2 from the ascii table then send the ascii value of 2 to the LCD
regards,
yh
Re: how to display a value in LCD

Posted:
Mon Dec 20, 2010 10:16 pm
by tst
oic.. thanks yh.
Re: how to display a value in LCD

Posted:
Tue Dec 21, 2010 6:38 am
by ABSF
Take a look on the P18 & 19 of the datasheet here:
http://www.stanford.edu/class/ee281/han ... asheet.pdfThere are 2 types of ROM codes in HD44780 - ROM A00 & A02. So if you're getting graphic characters as you mentioned in your post you might be have ROM code A02. If the ASC code you sent is above 0x80, it should be Japanese characters.
Did you refer to the PR12 project code for RTC? There is an example on how to convert decimal to ASCII. Very nice codes - "send_dec".
Allen
Re: how to display a value in LCD

Posted:
Sat Dec 25, 2010 7:54 pm
by shahrul
See example I display number
here.
It need to convert the integer.
- CODE: SELECT_ALL_CODE
void convert(int no, char base)
{char i;
for(i=0;i<=9;i++) di[i]=0;
i=0;
do{
di[i]=no%base;
no=no/base;
i=i+1;}
while(no!=0);
}
Re: how to display a value in LCD

Posted:
Tue Dec 28, 2010 12:28 am
by sich
ABSF WROTE:Did you refer to the PR12 project code for RTC? There is an example on how to convert decimal to ASCII. Very nice codes - "send_dec".
Glad to know that our hard work pays off! Really happy when people find what we did is useful

Re: how to display a value in LCD

Posted:
Tue Jan 04, 2011 3:32 pm
by tst
yeah...I solve the problem already. Thanks everyone.
Re: how to display a value in LCD

Posted:
Fri Jan 28, 2011 1:35 pm
by PICTRAIL
Please can someone help on this LCD error... My 2x16 LCD can only display black boxes on the first row but it's not displaying my real message. I would like to check is anyone can help.
Re: how to display a value in LCD

Posted:
Mon Mar 12, 2012 12:08 am
by Lam
My 2x16 LCD can only display black boxes on the first row but it's not displaying my real message.
I faced this problem too! Spend 2weeks+ time but still can't solve the problem. Hope anyone here can advice! =)
Re: how to display a value in LCD

Posted:
Mon Mar 12, 2012 1:45 pm
by hyng
Lam WROTE: My 2x16 LCD can only display black boxes on the first row but it's not displaying my real message.
I faced this problem too! Spend 2weeks+ time but still can't solve the problem. Hope anyone here can advice! =)
Please describe more about how you were connect the LCD. What hardware, microcontroller and code you use.
Photo of the connection also is helpful.