#include "16f877a.h"
#device ADC=8
#fuses XT,NOWDT,NOPROTECT,NOLVP,NODEBUG
#use delay(clock=4000000)
#define Pulse PIN_C0 //aquí manda pulso disparo al triac
int flag=0; //#include
#int_ext
void ext_isr()
{ flag=1; }
void main()
{
BYTE i, j, address, value;
int16 q, q1;
int16 retardo=0,data=200;
float p; q1=0;
output_low(Pulse);
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);
ext_int_edge(0,L_TO_H);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
do
{
if(flag)
{
data=read_adc();
retardo=(int16)(255-data)*32;
delay_us(retardo);
output_high(Pulse);
delay_us(40);
output_low(Pulse);
flag=0;
}
}while (TRUE);
}