lcd1602.c

来自「利用DS18B20」· C语言 代码 · 共 66 行

C
66
字号
#include "lcd1602.h"
#include "ds18b20.h"


void delay(void)
{
	unsigned int i,j;
	//for(i=0;i<1300;i++)
		for(j=0;j<20;j++);
}

	
void main(void)
{ 
 	unsigned char i,temp2[8];

 	char *str="temperature is ";
 	Lcd_Init();
 	ClrScreen();
 	Print(str);


 	while(1)
 	{
 
		ds18b20_init();

 		ds18b20_writecommand(0xcc);
 		ds18b20_writecommand(0x44);	 //转换
		delay();


 		ds18b20_init();
 		ds18b20_writecommand(0xcc);
 		ds18b20_writecommand(0xbe);	  //读


 		for(i=0;i<5;i++)
 		{
 	
 			temp[i]=ds18b20_readdata();
 		}
			ds18b20_init();
 			temperature_process(temp[0],temp[1]);
	
		if(!flag) //正
		{
			GotoXY(0,1);
			Print(zhen_temp);	
			Print(".");
			Print(xiaoshu_temp);
		}
		else   //负
		{
			GotoXY(0,1);
			Print("-");
			Print(zhen_temp);	
			Print(".");
			Print(xiaoshu_temp);

  	 }

	}
 	while(1);
	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?