单片机温度计设计仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
有AVR16芯片和AVR128芯片2个版本
单片机源程序如下:
- /*-------------------------------
- 作者:小新
- email:xuxing1261207@126.com
- --------------------------------*/
- #include <iom16v.h>
- #include <macros.h>
- #include "lcd.h"
- #include "ds18b20.h"
- unsigned int temp1=20,temp2=35;
- void main(void)
- {
- unsigned char i=0;
-
- DDRD=0xff;
- PORTD=0x00;
- DDRC=0x00;
- PORTC=0xFF;
- CLI();
- LCD_init();
- SEI();
- LCD_DisplayString(1,1,"Down: Up: ");
- LCD_DisplayString(2,1,"T=");
- while(1)
- {
- i=PINC;
- if((i&0x01)==0)
- {
- //while(!(i&0x01));
- temp1++;
- }
- if((i&0x04)==0)
- {
- //while(!(i&0x04));
- temp1--;
- }
-
- if((i&0x10)==0)
- {
- //while(!(i&0x01));
- temp2++;
- }
- if((i&0x40)==0)
- {
- //while(!(i&0x04));
- temp2--;
- }
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
DS18B20温度传感器protues仿真 avr16128 ds18b20单片机仿真程序.zip
(183.14 KB, 下载次数: 145)
|