Naren Rover
New Member
Hi Guys.I need help with this Program I'm using PIC16f886 controller
when I press a push Button a LED should blink , the program works fine
the button is connected to pin RB3 and LED to pin RA2.
Problem arises when i set Analog pin
when i enable analog pin AN11 which is in RB4, RB3 is not sensing Button Press.
i have attached the program can someone help me.. thank you
#include <xc.h>
#define BUTTON RB3
#define LED RA2
void main(void)
{
PORTA=0x00;
PORTB=0x00;
TRISA=0x00;
TRISB=0x18; //setting RB4(AN11),RB3 as inputs
ANSEL=0X00;
ANSELH=0X08; // enabling Analog pin AN11 pin
// ANSELH=0X00;
// RB3 senses button when analog pin is disabled which is in RB4
while(1)
{
if(BUTTON==0)
{
LED=1;
}
else
{
LED=0;
}
}
}
when I press a push Button a LED should blink , the program works fine
the button is connected to pin RB3 and LED to pin RA2.
Problem arises when i set Analog pin
when i enable analog pin AN11 which is in RB4, RB3 is not sensing Button Press.
i have attached the program can someone help me.. thank you
#include <xc.h>
#define BUTTON RB3
#define LED RA2
void main(void)
{
PORTA=0x00;
PORTB=0x00;
TRISA=0x00;
TRISB=0x18; //setting RB4(AN11),RB3 as inputs
ANSEL=0X00;
ANSELH=0X08; // enabling Analog pin AN11 pin
// ANSELH=0X00;
// RB3 senses button when analog pin is disabled which is in RB4
while(1)
{
if(BUTTON==0)
{
LED=1;
}
else
{
LED=0;
}
}
}