hello everyone..
I am having a trouble to interfacing gas sensor with pic16f877a.
how to make a code for a program that start a motor when the sensor detect a smoke.
I already modify some of the code that i found at other forum..here is the code that i made..i am using mikroc compiler
void main()
{
ADCON0 = 0xFF;
TRISC.F0=0;
PORTC.F0=0;
TRISC.F1=0;
PORTC.F1=0;
TRISC.F2=0;
PORTC.F2=0;
ADCON0=0b10000001;
ADCON1=0b01000100;
unsigned int temp;
unsigned double val;
unsigned float rs;
void main ()
{
while(1) // create infinite loop
{
temp= ADC_Read(0); // Read from pin RA0
val =(unsigned double)(temp);
rs=((1023*47000/val) -4700;
rs/=1000;
rs=rs/32.8;
if ( rs<0.35)
{
PortC.F0=1; // then RB6 will turn On
}
else if (rs<0.16)
{
PortC.F1=1;
}while(1);
}
} }
any help will ve appriciate..thx