Hi... I am reading a light sensor and am having issues with writing out the data to an LCD. I have figured out 1 way to do it, but am looking at alternate techniques and commands.
symbol light w3
'read light sensor - this will be a 5 digit number
count 2, 1000, light
'put lcd in mode to receive data
rs = lcddata
After I assign the variable (light), I need to parse each digit and send it to the
lcd.
I tried to use the following Table command, but it did not like the syntax... I can't figure out why. Can someone show me what is wrong?
TABLE 0, (light) ' doesnt like this syntax / assignment
for b8 = 0 to 4
readtable b8,b9
outbyte = b9
gosub lcdout
next b8
I then tried another technique - reading in 1 character at a time and saving in each value to a different variable, and then looping again to write out the digits in correct order to the lcd. This seems a bit tedious and unsophisticated. Can someone show me another method?
symbol light w3
'read light sensor - this will be a 5 digit number
count 2, 1000, light
'put lcd in mode to receive data
rs = lcddata
After I assign the variable (light), I need to parse each digit and send it to the
lcd.
I tried to use the following Table command, but it did not like the syntax... I can't figure out why. Can someone show me what is wrong?
TABLE 0, (light) ' doesnt like this syntax / assignment
for b8 = 0 to 4
readtable b8,b9
outbyte = b9
gosub lcdout
next b8
I then tried another technique - reading in 1 character at a time and saving in each value to a different variable, and then looping again to write out the digits in correct order to the lcd. This seems a bit tedious and unsophisticated. Can someone show me another method?
Code:
'******************************************************
'read digits 1 through 5
'this reads 1 digit at a time from the right
' if write out immediately, number will be reversed
'****************************************************** for counter = 1 to 5
outbyte = light // 10 + $30
select case counter
case 1
b8 = outbyte
case 2
b9 = outbyte
case 3
b10 = outbyte
case 4
b11 = outbyte
case 5
b12 = outbyte
endselect
light = light / 10
next counter
'********************************************
'now write the number in reverse / correct order, taking up positions 1-5
for counter = 1 to 5
select case counter
case 1
outbyte = b12
case 2
outbyte = b11
case 3
outbyte = b10
case 4
outbyte = b9
case 5
outbyte = b8
endselect
gosub lcdout
next counter
Last edited by a moderator: