30-03-2012, 12:27 PM | #28 |
Nhập môn đệ tử
Tham gia ngày: Feb 2012
Bài gửi: 4
: |
đo nhiệt độ dùng lm335 và 16f877a hiển thị led 7 đoạn
e mới học vdk...đang viết 1 mạch đo nhiệt độ dùng lm335 và 16f877a hiển thị led 7 đoạn
ko bik đoạn code e viết sai chỗ nào, mong ae giúp cho..thanks # include <16f877a.h> # fuses hs,nowdt,nolvp # DEVICE 16f877a*=16 ADC=10 # use delay (clock=4000000) int Maled[10]={0XC0,0XF9,0XA4,0XB0,0X99,0X92,0X82,0XF8,0X80,0X9 0}; int hc=0,hdv=0,nhietdo,giatriadc; # int_timer1 void ngattimer() { set_adc_channel(0); delay_ms(10); giatriadc=read_adc(); nhietdo=((giatriadc-558.558)/2.048); hc=nhietdo/10; hdv=nhietdo%10; set_timer1(40536); } void hienthi(); void main() { set_tris_a (0xff); set_tris_b (0x00); set_tris_c (0x00); setup_timer_1(t1_internal|t1_div_by_8); set_timer1(40536); enable_interrupts(int_timer1); enable_interrupts(global); setup_adc(adc_clock_internal); setup_adc_ports(AN0); while(1) { hienthi(); } } void hienthi() { output_high (pin_c0); output_low (pin_c1); output_b (Maled[hc]); delay_ms(5); output_high (pin_c1); output_low(pin_c0); output_b (Maled[hdv]); delay_ms (5); } sơ đồ mạch: thay đổi nội dung bởi: DunLop, 30-03-2012 lúc 04:10 PM. Lý do: bổ sung |
|
|