View Single Post
Old 06-05-2007, 09:37 PM   #25
huybo02
Đệ tử 4 túi
 
Tham gia ngày: Aug 2006
Bài gửi: 61
:
Code:
#include <16F877.h>
#device 16F877*=16 ADC=10
#include <math.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=1000000)
#define use_portd_lcd TRUE
#include<lcd.c>
long adc,nhietdo;
int8 a,b,c,d;
void tachhang(int&a,int&b,int&c,int&d);
char so[11] ="0123456789";
void main()
{
setup_adc(adc_clock_internal);
setup_adc_ports(AN0);
set_adc_channel(0);
delay_ms(100);

while(true)
{
adc=read_adc();
nhietdo = (adc-559)/0.2024;
tachhang(a,b,c,d);
lcd_init();
delay_ms(100);
lcd_putc(so[a]);
lcd_putc(so[b]);
lcd_putc(so[c]);
lcd_putc('.');
lcd_putc(so[d]);
delay_ms(900);
}
}

void tachhang(int&a,int&b,int&c,int&d)
{
   a=nhietdo/1000;
   b=(nhietdo%1000)/100;
   c=(nhietdo%100)/10;
   d=nhietdo%10;
}


/* 5V = 1024 muc =>1 muc ADC ung voi ap =4.88 => 10mV tuong ung voi 2.048 muc ADC
0oC = 273oK => 0oC ung voi muc dien the 2.73V ung voi 559 muc ADC
Nhiet do = dien the Analog/10 - 273
Tuong ung
Nhiet do = (adc -559)/2.024
Xuat gia tri nhiet do ra LED 7 doan hay LCD*/
Làm được rồi hi`. Dùng ADC 10bit Vref =5V Xuất ra LCD 4bit

thay đổi nội dung bởi: namqn, 06-05-2007 lúc 10:33 PM.
huybo02 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn