sending numbers direct to LCD

Bryang

Member
Hi all,
I've hooked up my 18X direct to a 16x2 LCD. it works fine writing a nominated variable string (like by using... EEPROM 0,"hello") into the EEPROM, and reading it a letter at a time to send it to the LCD.
What I have been trying to do is send a 3-character output - ala the readadc output from the LDR on the 18X Project Board - to the LCD. I know I'm getting the readadc into the PICAXE ok, but it appears to me that I need to convert it from a variable to a string, but I cannot work out how to do this!
No doubt something simple, but it's got be baffled! can anyone help?
Bryan.
 

Technical

Technical Support
Staff member
Simply use a # to output ascii
Instead of
serout 7,n2400,(b1)
use
serout 7,n2400,(#b1)
 

womai

Senior Member
What technical suggests will work for a serial LCD that you talk to with normal "serout" (the AXE033 in serial mode is one example). If you have a I2C connection (AXE033 in I2C mode) or if your LCD is a parallel LCD, you need to convert the number to a string yourself, e.g.

w0 = 12345
b2 = w0 / 10000
send b2 to LCD (prints "1")
b2 = w0 / 1000 % 10
send b2 to LCD (prints "2")
b2 = w0 / 100 % 10
send b2 to LCD (prints "3")
b2 = w0 / 10 % 10
send b2 to LCD (prints "4")
b2 = w0 % 10
send b2 to LCD (print "5")

This will print leading zeroes; a little more code is necessary to print spaces instead of leading zeroes. For word variables a loop may be more elegant though a little slower and needs one more word variable (untested code!):

w0 = 12345

w2 = 10000

print_loop:
b2 = w0 / w2 % 10
send b2 to LCD
w2 = w2 / 10
if w2 > 0 then goto print_loop


Wolfgang
 
Top