how to display a value in LCD

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

how to display a value in LCD

Postby tst » Sat Dec 18, 2010 11:52 pm

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..
tst
Apprentice
 
Posts: 33
Joined: Sat Sep 18, 2010 9:41 pm

Re: how to display a value in LCD

Postby yonghui » Mon Dec 20, 2010 8:03 pm

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
thanks&regards,
yh
yonghui
Professional
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: how to display a value in LCD

Postby tst » Mon Dec 20, 2010 10:16 pm

oic.. thanks yh.
tst
Apprentice
 
Posts: 33
Joined: Sat Sep 18, 2010 9:41 pm

Re: how to display a value in LCD

Postby ABSF » Tue Dec 21, 2010 6:38 am

Take a look on the P18 & 19 of the datasheet here:

http://www.stanford.edu/class/ee281/han ... asheet.pdf

There 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
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: how to display a value in LCD

Postby shahrul » Sat Dec 25, 2010 7:54 pm

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);
}
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: how to display a value in LCD

Postby sich » Tue Dec 28, 2010 12:28 am

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 ;)
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 604
Joined: Tue Apr 21, 2009 2:15 pm

Re: how to display a value in LCD

Postby tst » Tue Jan 04, 2011 3:32 pm

yeah...I solve the problem already. Thanks everyone.
tst
Apprentice
 
Posts: 33
Joined: Sat Sep 18, 2010 9:41 pm

Re: how to display a value in LCD

Postby PICTRAIL » Fri Jan 28, 2011 1:35 pm

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.
PICTRAIL
Apprentice
 
Posts: 40
Joined: Mon Dec 27, 2010 3:32 pm

Re: how to display a value in LCD

Postby Lam » Mon Mar 12, 2012 12:08 am

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! =)
Lam
Novice
 
Posts: 22
Joined: Thu Jan 26, 2012 7:54 pm

Re: how to display a value in LCD

Postby hyng » Mon Mar 12, 2012 1:45 pm

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.
User avatar
hyng
Moderator
 
Posts: 292
Joined: Thu Apr 16, 2009 11:35 am

Next

Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 1 guest