论坛元老
 
- 积分
- 6679
- 金钱
- 6679
- 注册时间
- 2015-8-25
- 在线时间
- 1036 小时
|
发表于 2017-4-8 15:05:06
|
显示全部楼层
#if 0与#endif之间的代码不执行,所有关于LCD显示的都注释掉了。
u8 t=0;
short temperature;
delay_init(); //延时函数初始化
uart_init(9600); //串口初始化为9600
LED_Init(); //初始化与LED连接的硬件接口
while(DS18B20_Init());
while(1)
{
if(t%10==0)//每100ms读取一次
{
temperature=DS18B20_Get_Temp();
if(temperature<0)
{
//LCD_ShowChar(60+40,150,'-',16,0); //显示负号
temperature=-temperature; //转为正数
}
//else LCD_ShowChar(60+40,150,' ',16,0); //去掉负号
//LCD_ShowNum(60+40+8,150,temperature/10,2,16); //显示正数部分
//LCD_ShowNum(60+40+32,150,temperature%10,1,16); //显示小数部分
printf("temperature=%f\r\n",temperature/10.0);
}
delay_ms(10);
t++;
if(t==20)
{
t=0;
LED0=!LED0;
}
} |
|