LCD serial display

How do I code a 3 digit number stored in the variable b10, to be displayed on a serial LCD screen 16 columns x 2 rows? I have used the following formula for a 2 digit #

b12=b10//10
b10=b10/10
b11=b10//10
let b11=b11+48, b11 is the 1st digit
let b12=b12+48, b12 is the 2nd digit

Thanks
 
Yes it works for a 2 digit number but I don't know how to extend it to a 3 digit number in the variable b10. All I am trying to do is display a 3 digit number that is stored in b10 to a serial display. Is there another way to do this, I am using a 28X1.

Thanks
 

hippy

Ex-Staff (retired)
b10 = 123
b12 = b10 / 100 // 10 + "0"
b11 = b10 / 10 // 10 + "0"
b10 = b10 / 1 // 10 + "0"

b12 = "1", b11 = "2", b10 = "3" - You can probably see the pattern needed to go up to five digits for word variables.

Or simply use the BINTOASCII command which does this all for you.
 

westaust55

Moderator
if using a byte variable,
then for example #b10 will work for values from 0 to 255.

if using a word variable,
then for example #w5 will work for values from 0 to 65535.
 

hippy

Ex-Staff (retired)
Using # in SEROUT is often good enough. It's downside is that it doesn't produce a fixed number of digits, no leading zeroes or trailing spaces which can create issues when displaying numbers on an LCD, though none of them insurmountable.
 

westaust55

Moderator
Using # in SEROUT is often good enough. It's downside is that it doesn't produce a fixed number of digits, no leading zeroes or trailing spaces which can create issues when displaying numbers on an LCD, though none of them insurmountable.
very true hippy.
for the 3 digit case when using the # method,
if formatting is a factor then for say the hundreds difgit need to check if number is <100 and if so send a space.
if formatting is not a big issue then can just send a space or two at the end of the number.


Comes down to:
The more information the poster/enquirer give forum members the better the answer they will receive
 
Top