标题: STM32可调时钟加温度显示源码 [打印本页]

作者: LGX123    时间: 2018-8-12 10:12
标题: STM32可调时钟加温度显示源码
该程序是在stm32开发板上实现功能的,DS18B20获取温度通过屏幕显示和串口打印出来,通过K_UP按键选择修改时间的哪个参数各自对应D1~D7指示灯亮,通过K_LEFT和K_DOWM改变数字的加减。

实物图:


stm32单片机源程序如下:
  1. #include "system.h"
  2. #include "SysTick.h"
  3. #include "led.h"
  4. #include "usart.h"
  5. #include "rtc.h"
  6. #include "tftlcd.h"
  7. #include "key.h"
  8. #include "exti.h"
  9. #include "DS18B20.h"


  10. /*******************************************************************************
  11. * 函 数 名         : main
  12. * 函数功能                   : 主函数
  13. * 输    入         : 无
  14. * 输    出         : 无
  15. *******************************************************************************/
  16. int main()
  17. {
  18.         u8 i=0;
  19.         float temper;
  20.         u8 temper_buf[6];
  21.         int temper1;
  22.        
  23.         SysTick_Init(72);
  24.         NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);  //中断优先级分组 分2组
  25.         LED_Init();
  26.         USART1_Init(9600);
  27.         RTC_Init();
  28.         TFTLCD_Init();
  29.         LED_Init();
  30.         KEY_Init();
  31.         My_EXTI_Init();
  32.         DS18B20_Init();
  33.        
  34.         FRONT_COLOR=YELLOW;
  35.        
  36.         LCD_ShowFontHZ(10,120,"当前温度为");
  37.         LCD_ShowFontHZ(80,150,"℃");
  38.        
  39.         while(1)
  40.         {
  41.                 i++;
  42.                 if(i%5==0)
  43.                 {
  44.                   temper=DS18B20_GetTemperture();
  45.                         temper1=temper*100;
  46.                         temper_buf[0]=temper1/10000+0x30;
  47.       temper_buf[1]=temper1%10000/1000+0x30;
  48.                         temper_buf[2]=temper1%1000/100+0x30;
  49.                         temper_buf[3]='.';
  50.                         temper_buf[4]=temper1%100/10+0x30;
  51.       temper_buf[5]=temper1%10+0x30;
  52.                         LCD_ShowString(10,150,tftlcd_data.width,tftlcd_data.height,24,(u8 *)temper_buf);
  53.                 }
  54.                 if(i%20==0)
  55.                 {
  56.                         led1=!led1;
  57.                 }
  58.                 delay_ms(10);
  59.         }
  60. }
复制代码

所有资料51hei提供下载:
可调时钟加温度显示.rar (327.7 KB, 下载次数: 45)



作者: 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