You are on page 1of 3

#include <16f877a.

h>

#device adc=10

#fuses XT, NOWDT

#use delay (clock = 4000000)

#include <lcd.c>

#include <math.h>

int cont=1;

#int_TIMER1

void timer1_isr (void) {// funcion

if (cont==3) {

enable_interrupts (int_timer2);

if (cont==6) {

disable_interrupts (int_timer2);

Cont=0;

set_timer1 (3036); // incremento del contador

cont++;

#int_timer2 void timer_isr (void) {

output_toggle (PIN_B1);

set_timer2 (11); // se carga el timer con el valor para generar 1khz

void main () {

output_low (PIN_B1);

setup_timer_1 (T1_INTERNAL | T1_DIV_BY_8); // CONFIGURACION DEL TIMER

set_timer1 (3036); // RECARGA EL TIMER 1

setup_timer_2 (T2_DIV_BY_4,128,1); // CONFIGURACION DEL TIMERR // RECARGA EL TIMER 2


set_timer2 (11);

enable_interrupts (global); // habilita todas las interrupciones

setup_adc_ports (AN0);

setup_adc (ADC_CLOCK_INTERNAL);

set_adc_channel (0);

lcd_init ();

float value, t;

lcd_gotoxy (1,1);

printf (lcd_putc,"TEMP = \337C");

while(1) {

value=read_adc ();

t=100.0*5.0*value/1023.0;

if (t<=25) {

output_high (PIN_B2);

enable_interrupts (int_TIMER1);

Else {

output_low (PIN_B2);

disable_interrupts (int_TIMER1);

If ( (t>25) & & (t<35) ) {

output_high (PIN_B3);

enable_interrupts (int_timer2);

output_high (PIN_B0);

lcd_gotoxy (4,2);

printf (lcd_putc,"MOTOR ON ");

Else {

output_low (PIN_B3);
disable_interrupts (int_timer2);

output_low (PIN_B0);

lcd_gotoxy (4,2);

printf (lcd_putc,"MOTOR OFF");

lcd_gotoxy (8,1);

printf (lcd_putc, " % f " , t);

delay_ms (100);

You might also like