标题:
STM32可调时钟加温度显示源码
[打印本页]
作者:
LGX123
时间:
2018-8-12 10:12
标题:
STM32可调时钟加温度显示源码
该程序是在stm32开发板上实现功能的,DS18B20获取温度通过屏幕显示和串口打印出来,通过K_UP按键选择修改时间的哪个参数各自对应D1~D7指示灯亮,通过K_LEFT和K_DOWM改变数字的加减。
实物图:
微信图片_20180812100017.jpg
(168.81 KB, 下载次数: 68)
下载附件
2018-8-12 10:11 上传
stm32单片机源程序如下:
#include "system.h"
#include "SysTick.h"
#include "led.h"
#include "usart.h"
#include "rtc.h"
#include "tftlcd.h"
#include "key.h"
#include "exti.h"
#include "DS18B20.h"
/*******************************************************************************
* 函 数 名 : main
* 函数功能 : 主函数
* 输 入 : 无
* 输 出 : 无
*******************************************************************************/
int main()
{
u8 i=0;
float temper;
u8 temper_buf[6];
int temper1;
SysTick_Init(72);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //中断优先级分组 分2组
LED_Init();
USART1_Init(9600);
RTC_Init();
TFTLCD_Init();
LED_Init();
KEY_Init();
My_EXTI_Init();
DS18B20_Init();
FRONT_COLOR=YELLOW;
LCD_ShowFontHZ(10,120,"当前温度为");
LCD_ShowFontHZ(80,150,"℃");
while(1)
{
i++;
if(i%5==0)
{
temper=DS18B20_GetTemperture();
temper1=temper*100;
temper_buf[0]=temper1/10000+0x30;
temper_buf[1]=temper1%10000/1000+0x30;
temper_buf[2]=temper1%1000/100+0x30;
temper_buf[3]='.';
temper_buf[4]=temper1%100/10+0x30;
temper_buf[5]=temper1%10+0x30;
LCD_ShowString(10,150,tftlcd_data.width,tftlcd_data.height,24,(u8 *)temper_buf);
}
if(i%20==0)
{
led1=!led1;
}
delay_ms(10);
}
}
复制代码
所有资料51hei提供下载:
可调时钟加温度显示.rar
(327.7 KB, 下载次数: 45)
2018-8-12 14:28 上传
点击文件名下载附件
下载积分: 黑币 -5
作者:
hhkjvip
时间:
2019-12-30 10:55
感谢楼主分享,谢谢
作者:
潘志豪
时间:
2020-1-2 00:37
谢谢楼主分享
作者:
tj小学渣
时间:
2020-7-21 20:24
感谢楼主,感觉楼主可能是tj学长?
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1