View Full Version : Again about array
fratello
- 6th March 2018, 09:22
Hi !
I tried to read 10 samples of ADC values and sending to LCD display.
DataW var word[10]
i var byte
main:
for i=0 to 9
ADCON0.1 = 1 ' Start conversion
While ADCON0.1=1:Wend ' Wait for conversion
DataW.HighByte=ADRESH ' Read variable from ADC and save
DataW.LowByte=ADRESL
pause 50
next i
IF DATAW < 1023 THEN
LCDOUT $fe,1
for i=0 to 9
lcdout dec dataw[i], " "
next i
endfor
PAUSE 1000
Endif
Goto main
But on LCD I have the value of ADC and seven "0". (like : 77 0 0 0 0 0 0 0)
Please, help ! What I do wrong ?
Thanks !
pedja089
- 6th March 2018, 11:05
Where you index your array here
for i=0 to 9
ADCON0.1 = 1 ' Start conversion
While ADCON0.1=1:Wend ' Wait for conversion
DataW.HighByte=ADRESH ' Read variable from ADC and save
DataW.LowByte=ADRESL
pause 50
next i
Also high and low byte will just use first word of array.
IF DATAW < 1023 THEN this also only reference first word of array.
Array must be used as in LCDOUT.
So your code should look like this
TmpW var word
DataW var word[10]
i var byte
main:
for i=0 to 9
ADCON0.1 = 1 ' Start conversion
While ADCON0.1=1:Wend ' Wait for conversion
TmpW .HighByte=ADRESH ' Read variable from ADC and save
TmpW .LowByte=ADRESL
DataW[i]=TmpW
pause 50
next i
LCDOUT $fe,1
for i=0 to 9
lcdout dec dataw[i], " "
next i
fratello
- 6th March 2018, 12:52
Thank you verry much ! Works fine !
I really appreciate it !
...and how to continue to second line of LCD ? There is no room for ten values on the first line ...
Something like this ?
LCDOUT $fe,1
for i=0 to 3
lcdout dec dataw[i], ","
pause 500
next i
lcdout $FE, $C0
for i=4 to 7
lcdout dec dataw[i], ","
pause 500
next i
Note : there is room only for four values on the line
pedja089
- 6th March 2018, 13:19
That should work.
Scampy
- 6th March 2018, 17:37
...and how to continue to second line of LCD ? There is no room for ten values on the first line ...
Line 1 = $80
Line 2 = $C0
If you have a 4 line LCD
Line 1 = $fe,$80,
Line 2 = $fe,$C0,
Line 3 = $fe,$94,
Line 4 = $fe,$d4,
Ioannis
- 7th March 2018, 20:46
Note : there is room only for four values on the line
Then you can only fit 8 values!
For 10 I guess you have to use a larger display or maybe use hex notation.
Ioannis
fratello
- 8th March 2018, 06:20
Yes, I use only 8 value.
Thank you, all !
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.