HI
I have a 0-9 BCD hooked to PortC0-3 using 22k resistors tied to 5v. I am using a PIC16F877A. Yea I know I could have used the built-in pull ups on another port, but the board was built before I figured that one out. Below is the code.

Here is my deal, the value I see displayed on the LCD and the BCD position don't match at all. I would think that no matter how I have the four pins matched to PortC0-3, I would get ten different values. I get FIVE, lol. Please take a look at the code and let me know if this is a software or hardware problem.

One other question while I am here. I would like to use PortC4-7 as outputs. With the code below, where I use BCD=PortC, will that be a problem.

Thanks in advance for the help
Toby

BCD Display
0 7
1 7
2 3
3 3
4 5
5 5
6 1
7 1
8 6
9 6

include "bs2defs.bas"

BCD var byte 'BCD Position
'For LCD
Define LCD_DREG PORTD
Define LCD_DBIT 4
Define LCD_RSREG PORTE
Define LCD_RSBIT 0
Define LCD_EREG PORTE
Define LCD_EBIT 1

ADCON1 = 7
TRISD = 0
TRISC = $FF

BCD = 0

Loop:
BCD=PORTc
BCD=BCD & $0F
Gosub Display
pause 100
Goto Loop:

Display: Lcdout $fe, 1
Lcdout "BCD ", dec BCD
Return