hi..
i write one program to identify the switch pressed, which is connected to pic 18f port B0. when switch is pressed,it is connected to ground. but i m not getting the proper output.. USART communication is ok... here is my code..
void main(void)
{
int x;
TRISB=1;
LATB=1;
INTCON2bits.RBPU=0; //enable pull up
WPUBbits.WPUB0=1;
ANSELH=0x00;
EnableUART();
printf("plz press key");
while(1)
{
x=LATBbits.LATB0 ;
if (x==0)
printf("key pressed");
}
}
Please check with your circuit using multimeter, while pressing the button the voltage gets dropped or not, i not sure about that syntax of your compiler, but u have to scan the input level of pin by using the trisb register....