atifsheikh_91
Member level 1
Compiler Used = MicroC for PIC
MicroController= Pic16f877a; (and tried other too).
hi all; I am designing a circuit in which ; a potentiometer is used to change the output of Portb; when the voltage is above 2.5 PORTB=1 and when it is low PORTB=0.
Please help me out ; i have chk a simple program with ADC ( given in MICROC) and it is working fine.
code is as
/* task is to make PORTB=1 when read>2.5 and PORTB=0 else; */
// I have tried different program ( without comparassion ) they are working fine
// but this comparission is not doing right operation
void main() {
float read;
ANSEL=0b00000001;
trisa=0xff;
TRISB=0X00;
portb=0x00;
ADC_Init();// ADC initiallized
while(1){
read=ADC_Read(0);
if(read>2.5)
{
portb=0xff;
}
else if(read<2.5)
{
portb=0x00;
}
}
}
Proteus Circuit is attached
Please help me out
MicroController= Pic16f877a; (and tried other too).
hi all; I am designing a circuit in which ; a potentiometer is used to change the output of Portb; when the voltage is above 2.5 PORTB=1 and when it is low PORTB=0.
Please help me out ; i have chk a simple program with ADC ( given in MICROC) and it is working fine.
code is as
/* task is to make PORTB=1 when read>2.5 and PORTB=0 else; */
// I have tried different program ( without comparassion ) they are working fine
// but this comparission is not doing right operation
void main() {
float read;
ANSEL=0b00000001;
trisa=0xff;
TRISB=0X00;
portb=0x00;
ADC_Init();// ADC initiallized
while(1){
read=ADC_Read(0);
if(read>2.5)
{
portb=0xff;
}
else if(read<2.5)
{
portb=0x00;
}
}
}
Proteus Circuit is attached
Please help me out