Documentos de Académico
Documentos de Profesional
Documentos de Cultura
h>
#fuses INTRC_IO,NOWDT,MCLR,NOPROTECT //ordenes para el programado
#Use standard_Io(A)
#use delay(clock=4000000)
// LED DE SENSOR
// DATO ENVIADO
int dato,m=1,ir=0;
int count,act_IR=0;
int ir1,act;
int ir1_1=1;
int16 contador=0;
#int_TIMER1
Void TIMER1_temporizador(void)
{ if(act==1)
{if((ir1_1==0)) // SIGUEN ACTIVOS LOS SENSORES?
{contador++;}
}
}
#int_TIMER0
Void TIMER0_isr(void) // envio de datos codificados.
{ dato++;
if(dato==2)
{ if(m==0)
{OUTPUT_HIGH(FM1);m=1;}
else
{OUTPUT_LOW(FM1);m=0;}
}
if(dato==4)
{dato=0;
if(act_IR==1)
{count++;
if(count==6) // CONTADOR PARA DESACTIVACION
{act_IR=0;count=0;ir1_1=1;}}
else
{if(counT>0)
{ir1_1=0;count=0;}
else
{ir1_1=1;}
}
}
}
void main(){
//-----------------------configuro el timer 0---------------------------setup_timer_0(RTCC_INTERNAL|RTCC_DIV_64);//clock interno
enable_interrupts(INT_TIMER0);// activar interrupcion Timer0 (interna)
while(TRUE)
{
if(dato==1)
{ir=input(SENSOR_IR1);
if(ir==1)
{ir1=0;act_IR=1;
OUTPUT_HIGH(PIN_A0);
}
else
{ir1=1;act_IR=0;
OUTPUT_LOW(PIN_A0);
}
}
if(contador==30)
{ act=0;
//if((ir1_1==0)) // SENSORES
// {
// OUTPUT_HIGH();
// SI,
if((ir1_1==0)) // SENSORES
{if(contador<30)
{act=1;} // activa el contador
}
else // DESACTIVA LA ALARMA
{output_low(LED_ESTADO); // SENSOR INACTIVO
contador=0;act=0;} // reinicia el contador
}
}
}