标题: 基于STM32F103ZET6的温度报警器 [打印本页]

作者: 川川line    时间: 2019-12-20 02:05
标题: 基于STM32F103ZET6的温度报警器
//#include "string.h"
#include "stm32f10x.h"
#include "system.h"
#include "SysTick.h"
#include "led.h"
#include "usart.h"
#include "tftlcd.h"
#include "beep.h"
#include "key.h"
#include "ds18b20.h"
u8 waring[] = {10,34}; //默认报警温度范围
u8 *p = waring;
u8 data[200];

int main(void)
{
u8 t=0;
float temperature;
int tmp;

LED_Init();//LED初始化
KEY_Init();//按键初始化
SysTick_Init(72);//延时初始化
//NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);  //中断优先级分组 分2组
USART1_Init(9600);
TFTLCD_Init();   //LCD初始化
BEEP_Init();//蜂鸣器初始化

FRONT_COLOR=RED;
LCD_ShowFontHZ(30,40,"张川");
LCD_ShowString(30,80,tftlcd_data.width,tftlcd_data.height,16,"201607014123");

while(DS18B20_Init())//ds18b20初始化
{
  LCD_ShowString(30,100,tftlcd_data.width,tftlcd_data.height,16,"DS18B20 Error");
  delay_ms(200);
  LCD_Fill(30,100,100,66,WHITE);
  delay_ms(200);
}

LCD_ShowString(30,100,tftlcd_data.width,tftlcd_data.height,16,"DS18B20 OK!");
FRONT_COLOR=BLUE;
LCD_ShowString(30,130,tftlcd_data.width,tftlcd_data.height,16,"xiaxian:");
LCD_ShowString(30,150,tftlcd_data.width,tftlcd_data.height,16,"shangxian:");

while(1)
{
  KEY_SET();
  if(t % 10 == 0)//100ms读取一次
  {
   temperature = DS18B20_GetTemperture();
   if(0 > temperature)
   {
    LCD_ShowChar(30+80,170,'-',16,0);
    temperature = -temperature;
   }
   else LCD_ShowChar(30+80,170,' ',16,0);
   
   sprintf((char *)data,"Temperate:%.2f",temperature);
    LCD_ShowString(30,170,tftlcd_data.width,tftlcd_data.height,16,data);
   //LCD_ShowNum(30+80+8,170,temperature/1,2,16);
   //LCD_ShowNum(30+80+32,170,temperature%10,1,16);
   
   LCD_ShowNum(30+80+8,130,waring[0],2,16);
   LCD_ShowNum(30+80+8,150,waring[1],2,16);  
  }
  
  t++;
  if(t%20==0)
  {
   led1 = !led1;
  }
  delay_ms(10);
  
  tmp = (int)temperature;
  if((tmp<=waring[0]) || (tmp >= waring[1]))
  {
   beep = !beep;
   led2 = 1;
  }
  else
  {
   beep = 0;
   led2 = 0;
  }
}  
}

温度报警器.docx

5.31 MB, 下载次数: 76, 下载积分: 黑币 -5

温度报警器.rar

366.54 KB, 下载次数: 111, 下载积分: 黑币 -5


作者: 2719221825zy    时间: 2021-11-15 19:12
程序能运行,但烧入进板子里就没用了这个
作者: hjh2047    时间: 2021-12-6 14:17
2719221825zy 发表于 2021-11-15 19:12
程序能运行,但烧入进板子里就没用了这个

我也是,怎么解决





欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1