Hi, I have made a program in which I ma using inbuilt ADC module of Pic 16F887. It is a simple program in which AN0 of port a is selected as analog input. I gave a variable supply to analog pin and compared it with 3 volt. If the variable voltage is greater than 3 volt then led should blink..but it didn't. I compiled the program using MicroPro C and it did not give any error but led is not blinking. I wonder that my program has some error...and here I need your help to understand what is going wrong in program.
Here is a program
Here is a program
Rich (BB code):
# include<built_in.h>
void delay();
void ADC_Init();
void ADC_Get_Sample();
sbit led at PORTA.B1;
void main() {
int value;
TRISA=0x01;
ANSEL=0X01;
do
{
delay();
ADC_Init();
delay();
ADC_Get_Sample(1);
delay();
value= ADRESH*256+ADRESL;
if(value>3)
led=1;
else
led=0;
}
while(1);
}
void delay()
{
int i,j;
for(i=0;i<255;i++)
{
for(j=0;j<255;j++);
}
}