And of course since the PICBasic manual example uses PORTA and you're using a PIC16F877A which has Comparators and ADC's you remembered to switch PORTA into DIGITAL mode?