欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
基于stm32單片機Proteus仿真溫度采集DS18B20實驗
[打印本頁]
作者:
XFAY
時間:
2022-7-14 10:13
標題:
基于stm32單片機Proteus仿真溫度采集DS18B20實驗
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
51hei.png
(21.94 KB, 下載次數(shù): 49)
下載附件
2022-7-14 16:32 上傳
這里展示主函數(shù)
#include "system.h"
#include "led.h"
#include "ds18b20.h"
//打印浮點型數(shù)據(jù),proteus不能有效打印浮點型數(shù)據(jù)
void PrintfFloat(float value)
{
int tmp,tmp1,tmp2,tmp3,tmp4,tmp5,tmp6;
tmp=(int)value;
tmp1=(int)((value-tmp)*10)%10;
tmp2=(int)((value-tmp)*100)%10;
tmp3=(int)((value-tmp)*1000)%10;
tmp4=(int)((value-tmp)*10000)%10;
tmp5=(int)((value-tmp)*100000)%10;
tmp6=(int)((value-tmp)*1000000)%10;
printf("%d.%d%d%d%d",tmp,tmp1,tmp2,tmp3,tmp4);
}
int main()
{
u8 i=0;
u16 temper;
float value;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //中斷優(yōu)先級分組 分2組
LED_Init();
USART1_Init(115200);
while(DS18B20_Init())
{
printf("DS18B20檢測失敗,請插好!\r\n");
delay_ms(500);
}
printf("DS18B20檢測成功!\r\n");
while(1)
{
i++;
if(i%20==0)
{
LED1=!LED1;
}
if(i%50==0)
{
temper=DS18B20_Get_Temp();
if((temper&0xf800)==0xf800)
{
temper=(~temper)+1;
printf("檢測的溫度為:- ");
}
else
{
printf("檢測的溫度為: ");
}
value=(float)temper*0.0625;
PrintfFloat(value);
printf("\r\n");
}
delay_ms(10);
}
}
Keil代碼下載:
Keil工程.7z
(313.62 KB, 下載次數(shù): 114)
2022-7-14 16:36 上傳
點擊文件名下載附件
可自行下載查看
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1