Winch
Member
Hello,
On port B of a 16F883 I connected a LCD. Now I want to use the analog output of RB0 (AN12).
I do not get the correct digital result on my screen? See below the code I use.
With ANSELH and TRISB I first make the right zettings, then I read Adcin 12 and write this to AN12.
However, the result is a too high digital number?
It must be possible to use together a display and an analog input? Or not?
Has anyone done this before?
On port B of a 16F883 I connected a LCD. Now I want to use the analog output of RB0 (AN12).
I do not get the correct digital result on my screen? See below the code I use.
With ANSELH and TRISB I first make the right zettings, then I read Adcin 12 and write this to AN12.
However, the result is a too high digital number?
It must be possible to use together a display and an analog input? Or not?
Has anyone done this before?
Code:
While startbutton = 3
Gosub timer
ADCON0 = %01110011 'Channel 02 (AN0/AN3) as a/d selected (CHS2:CHS0), ADCS1&ADCS0 bit are selected as Fosc/8
Adcin 4, an4 'read AN4 and write value to AN4
If timer1 = 5 Then
timer1 = 0
ANSELH = %00010000
TRISB = %00000001
Adcin 12, an12 'read AN12 and write value to AN12
ANSELH = %00000000
TRISB = %00000000
Endif
Lcdcmdout LcdLine1Pos(1) 'write from first position
Lcdout "C v" 'write the word "Colt" and "volt" on the screen!
Lcdcmdout LcdLine1Pos(5) 'write from position 5
Lcdout #an4 'just to see on the screen what the digital number is!
Lcdcmdout LcdLine2Pos(1) 'write from first position
Lcdout "W v" 'write the word "Warm" and "volt" on the screen!
Lcdcmdout LcdLine2Pos(5) 'write from position 5
Lcdout #an12 'just to see on the screen what the digital number is!
While select_sw2 = 0
startbutton = 0
timer1 = 0
Lcdcmdout LcdClear
selectbutton = 4
Gosub selectbutton4
Wend
WaitMs 100
Wend
Last edited: