Ok, here is the last stable working version i had (note: i have changed the values to abc just because it was quicker to write and i kept messing up before :-(
i have been messing about with it since (with minimal success, like i said, ive been playing with hardware) but this is it...
Define ADC_CLOCK = 3 'default value is 3
Define ADC_SAMPLEUS = 10 'default value is 20
Define LCD_BITS = 8 'allowed values are 4 and 8 - the number of data interface lines
Define LCD_DREG = PORTD
Define LCD_DBIT = 0 '0 or 4 for 4-bit interface, ignored for 8-bit interface
Define LCD_RSREG = PORTC
Define LCD_RSBIT = 0
Define LCD_EREG = PORTC
Define LCD_EBIT = 1
Define LCD_RWREG = 0 'set to 0 if not used, 0 is default
Define LCD_RWBIT = 0 'set to 0 if not used, 0 is default
Define LCD_COMMANDUS = 100 'delay after LCDCMDOUT, default value is 5000
Define LCD_DATAUS = 10 'delay after LCDOUT, default value is 50
Define LCD_INITMS = 1 'delay used by LCDINIT, default value is 100
'the last three Define directives set the values suitable for simulation; they should be omitted for a real device
'------------------------------------
'setup temp variables
Dim abc4 As Byte
Dim abc3 As Byte
Dim abc2 As Byte
Dim abc1 As Byte
Dim abc0 As Byte
Dim temp3 As Word
Dim binval As Word
Dim val0 As Word
'ADCON0 = %01000001 'adcchan0
'ADCON1 = %10001011 'Dis clk div,,,an0 > an3 analaog rest dig
TRISA = %00000001
TRISB = %11111111 'all inputs on portb
TRISC = %11111100
'TRISD = 0x00
'TRISE.2 = 0
'TRISE.0 = 0
'-----------------------------------------------------
Lcdinit
Lcddefchar 0, 31, 31, 31, 31, 31, 31, 31, 31
Lcddefchar 1, %00011111, %00011111, %00011111, %00011111, %00011111, %00011111, %00011111, %00011111
Lcdout 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
Lcdcmdout LcdLine2Home
Lcdout 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
WaitMs 1000
Lcdcmdout LcdHome
Lcdout "**Initialising**"
Lcdcmdout LcdLine2Home
Lcdout "*****FLIPS******"
WaitMs 750
Lcdcmdout LcdHome
Lcdout " PLEASE "
Lcdcmdout LcdLine2Home
Lcdout " WAIT "
WaitMs 750
main0:
Lcdcmdout LcdClear
main:
Gosub readadc
Goto main
End
'scale the 5V input to 4.88v using a resistive divider
readadc:
'read adc word
Adcin 0, val0
binval = val0 'rename for the bin2asc subr
Gosub bin2asc
Lcdcmdout LcdHome
Lcdout "Percent: ", abc3, abc2, abc1, ".", abc0, "%"
'scale the 5V input to 4.88v using a resistive divider
readadc:
'read adc word
Adcin 0, val0
binval = val0 'rename for the bin2asc subr
binval = binval / 5 'reduces 1000 to 200
Gosub bin2asc
Lcdcmdout LcdLine2Home
Lcdout "Volume: ", abc2, abc1, ".", abc0, "L"
Return
bin2asc:
'abc4 = binval / 10000' add these 4 lines for 16 bit conv
'temp3 = binval Mod 10000
'abc3 = temp3 / 1000
'temp3 = binval Mod 1000
abc3 = binval / 1000 'delete for 16 bit conv
temp3 = binval Mod 1000 'delete for 16 bit
abc2 = temp3 / 100
temp3 = temp3 Mod 100
abc1 = temp3 / 10
abc0 = temp3 Mod 10
abc4 = abc4 Or 0x30
abc3 = abc3 Or 0x30
abc2 = abc2 Or 0x30
abc1 = abc1 Or 0x30
abc0 = abc0 Or 0x30
WaitMs 250
Return
and ive only got 6 hours of my evaluation OS left