// khai bao tien chi thi
#include <16F877A.h>
#include <def_877a.h>
#device *=16 adc=10 // khai bao adc 10bit
#fuses NOWDT,PUT,NOPROTECT,HS,NOPUT,NODEBUG,NOBROWNOUT,NO LVP,NOCPD,NOWRT
#use delay(clock=20m)
#use fast_io(c)
#include <lcd_lib_4bit.c>
#define den RD2
#define quat RD3
//int16 value1, value2, value3;
signed int16 temp1,temp2,temp3;
void main()
{
set_tris_a(0xff);
set_tris_b(0x00);
set_tris_c(0x00);
set_tris_d(0x00);
set_tris_e(0x00);
setup_adc_ports(ALL_ANALOG);//cai dat cac chan la anlog
setup_adc(ADC_CLOCK_INTERNAL);
lcd_Init();
LCD_PutCmd(0x80);
printf(lcd_putchar,"do an tich hop 1");
delay_ms(1000);
lcd_putcmd(0x01);
delay_ms(1000);
LCD_putcmd(0x80);
printf(lcd_putchar," GVHD ");
delay_ms(1000);
lcd_putcmd(0xc0);
printf(lcd_putchar," Ng Trung Thanh ");
delay_ms(1000);
LCD_PutCmd(0x01);
delay_ms(1000);
LCD_PutCmd(0x80);
printf(lcd_putchar," SVTH ");
delay_ms(1000);
LCD_PutCmd(0x01);
LCD_putcmd(0xc0);
printf(LCD_putchar,"Dao Thi Thao Ly ");
LCD_PutCmd(0x80);
printf(lcd_putchar, "Do Dinh Luyen");
delay_ms(1000);
den=1;
quat=1;
LCD_PutCmd(0x01);
while(true)
{
//lay nhiet do kenh 1
set_adc_channel(0);
delay_ms(10);
temp1=(signed int16)read_adc();
temp1=temp1/2.048;
//lay nhiet do kenh 2
set_adc_channel(1);
delay_ms(10);
temp2=(signed int16)read_adc();
temp2=temp2/2.048;
//lay nhiet do kenh 3
set_adc_channel(2);
delay_ms(10);
temp3=(signed int16)read_adc();
temp3=temp3/2.048;
{
LCD_PutCmd(0x80);
printf(lcd_putchar,"T1");
LCD_PutCmd(0xc0);
printf(lcd_putchar,"%2ld",temp1);
LCD_PutCmd(0x80 + 6);
delay_us(20);
printf(lcd_putchar,"T2");
LCD_PutCmd(0xc0 + 6);
printf(lcd_putchar,"%2ld",temp2);
LCD_PutCmd(0x80 + 13);
delay_us(20);
printf(lcd_putchar,"T3 ");
LCD_PutCmd(0xc0 + 12); //
printf(lcd_putchar,"%2ld",temp3);
// dieu khien quat va bong den
if(temp1> 37 && temp2> 37 && temp3> 37) quat = 1;
else quat = 0;
//! if(temp1< 37 && temp2< 37 && temp3< 37) quat = 0;
if(temp1< 36 && temp2< 36 && temp3< 36) den = 1;
else den = 0;
}
}
}
#include <16F877A.h>
#include <def_877a.h>
#device *=16 adc=10 // khai bao adc 10bit
#fuses NOWDT,PUT,NOPROTECT,HS,NOPUT,NODEBUG,NOBROWNOUT,NO LVP,NOCPD,NOWRT
#use delay(clock=20m)
#use fast_io(c)
#include <lcd_lib_4bit.c>
#define den RD2
#define quat RD3
//int16 value1, value2, value3;
signed int16 temp1,temp2,temp3;
void main()
{
set_tris_a(0xff);
set_tris_b(0x00);
set_tris_c(0x00);
set_tris_d(0x00);
set_tris_e(0x00);
setup_adc_ports(ALL_ANALOG);//cai dat cac chan la anlog
setup_adc(ADC_CLOCK_INTERNAL);
lcd_Init();
LCD_PutCmd(0x80);
printf(lcd_putchar,"do an tich hop 1");
delay_ms(1000);
lcd_putcmd(0x01);
delay_ms(1000);
LCD_putcmd(0x80);
printf(lcd_putchar," GVHD ");
delay_ms(1000);
lcd_putcmd(0xc0);
printf(lcd_putchar," Ng Trung Thanh ");
delay_ms(1000);
LCD_PutCmd(0x01);
delay_ms(1000);
LCD_PutCmd(0x80);
printf(lcd_putchar," SVTH ");
delay_ms(1000);
LCD_PutCmd(0x01);
LCD_putcmd(0xc0);
printf(LCD_putchar,"Dao Thi Thao Ly ");
LCD_PutCmd(0x80);
printf(lcd_putchar, "Do Dinh Luyen");
delay_ms(1000);
den=1;
quat=1;
LCD_PutCmd(0x01);
while(true)
{
//lay nhiet do kenh 1
set_adc_channel(0);
delay_ms(10);
temp1=(signed int16)read_adc();
temp1=temp1/2.048;
//lay nhiet do kenh 2
set_adc_channel(1);
delay_ms(10);
temp2=(signed int16)read_adc();
temp2=temp2/2.048;
//lay nhiet do kenh 3
set_adc_channel(2);
delay_ms(10);
temp3=(signed int16)read_adc();
temp3=temp3/2.048;
{
LCD_PutCmd(0x80);
printf(lcd_putchar,"T1");
LCD_PutCmd(0xc0);
printf(lcd_putchar,"%2ld",temp1);
LCD_PutCmd(0x80 + 6);
delay_us(20);
printf(lcd_putchar,"T2");
LCD_PutCmd(0xc0 + 6);
printf(lcd_putchar,"%2ld",temp2);
LCD_PutCmd(0x80 + 13);
delay_us(20);
printf(lcd_putchar,"T3 ");
LCD_PutCmd(0xc0 + 12); //
printf(lcd_putchar,"%2ld",temp3);
// dieu khien quat va bong den
if(temp1> 37 && temp2> 37 && temp3> 37) quat = 1;
else quat = 0;
//! if(temp1< 37 && temp2< 37 && temp3< 37) quat = 0;
if(temp1< 36 && temp2< 36 && temp3< 36) den = 1;
else den = 0;
}
}
}
Comment