#include<16f877a.h>
#fuses hs
#device adc=8
#use delay(clock=4m)
int8 i,data;
int deger;
#int_timer0
void timer0()
{
i++;
if(i==0) output_high(pin_c1);
if(i==data) output_low(pin_c1);
SET_TIMER0(238);
}
void main()
{
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_4);
SET_TIMER0(238);
enable_interrupts(INT_TIMER0);
enable_interrupts(GLOBAL);
SETUP_ADC(ADC_CLOCK_INTERNAL);
SETUP_ADC_PORTS(ALL_ANALOG);
output_low(pin_c1);
data=0;
while(true)
{
SET_ADC_CHANNEL(0);
delay_us(20);
deger=read_adc();
data=30.0*deger/255.0;
}
}
Hiç yorum yok:
Yorum Gönder
Her yorum bilgidir. Araştırmaya devam...