cde
TRANSCRIPT
Theo minh thi nu nh phai o xa thi nn dung ds18b20 giao tip theo chun 1 wire. iu c bit la dung nhiu ds18b20 nhng chi mt 1 chn iu khin. Vi la giao tip bng s vi vy khng s anh hng bi nhiu.Tng ban code giao tip ds18b20 dung atmega 16 minh a test ok trn mach tht.LCD 16x2 ni portA ds18b20 ni portB.7 code nap vao la chay.http://codientu.org/threads/giup-e-do-nhiet-do-su-dung-4-lm35-voi-avr-voi.617/page-4
/*****************************************************This program was produced by theCodeWizardAVR V2.03.4 StandardAutomatic Program Generator Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l.http://www.hpinfotech.com Project :Version :Date : 10/31/2012Author :Company :Comments: Chip type : ATmega16Program type : ApplicationClock frequency : 12.000000 MHzMemory model : SmallExternal RAM size : 0Data Stack size : 256*****************************************************/ #include #include #include // 1 Wire Bus functions#asm .equ __w1_port=0x18 ;PORTB .equ __w1_bit=7#endasm#include // DS1820 Temperature Sensor functions#include // maximum number of DS1820 devices// connected to the 1 Wire bus#define MAX_DS18b20 8// number of DS1820 devices// connected to the 1 Wire busunsigned char ds18b20_devices;// DS1820 devices ROM code storage area,// 9 bytes are used for each device// (see the w1_search function description in the help)unsigned char ds18b20_rom_codes[MAX_DS18b20][9]; // Alphanumeric LCD Module functions#asm .equ __lcd_port=0x1B ;PORTA#endasm#include void lcd_putnum(float so, char x,char y){long t,c,d;long tp1,tp2,tp3,tp4;float temp1,temp2;t=so/100;// lay phan tramc= (so-100*t)/10;// lay hang chucd= so-100*t-10*c;// lay hang don viif(so