⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 DS18B20温度测量-完整源代码
💻 C
字号:
#include<stm32f10x_lib.h>
#include<string.h>
#include<stdio.h>
#include"ds18b20.h"
#include"STM32_Init.h"
#include"TFT200.h"

#define led1 (1<<6)	//led1用来指示是否超过指定温度
#define alarm 30    //警戒温度30
int value=0;
char s[];
int main(void)
{
	stm32_Init();
	LCD_Init();
	LCD_Clear_Screen(Blue);
	LCD_PutString(50,30,"DS18B20测温实验",Red,Yellow);

	for(;;)
	{
		value=readtemperature();
		if(value>=30)
		GPIOB->ODR|=led1;  //如果温度超过30度,则led1亮
		else
		GPIOB->ODR&=~led1;  //低于30度,则灭led1
		sprintf(s,"温度:%d",value); 
		LCD_PutString(70,70,s,Red,Yellow);
	}
		
}






⌨️ 快捷键说明

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