|
該程序是在stm32開發(fā)板上實(shí)現(xiàn)功能的,DS18B20獲取溫度通過屏幕顯示和串口打印出來,通過K_UP按鍵選擇修改時間的哪個參數(shù)各自對應(yīng)D1~D7指示燈亮,通過K_LEFT和K_DOWM改變數(shù)字的加減。
實(shí)物圖:
微信圖片_20180812100017.jpg (168.81 KB, 下載次數(shù): 68)
下載附件
2018-8-12 10:11 上傳
stm32單片機(jī)源程序如下:
- #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"
- /*******************************************************************************
- * 函 數(shù) 名 : main
- * 函數(shù)功能 : 主函數(shù)
- * 輸 入 : 無
- * 輸 出 : 無
- *******************************************************************************/
- int main()
- {
- u8 i=0;
- float temper;
- u8 temper_buf[6];
- int temper1;
-
- SysTick_Init(72);
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //中斷優(yōu)先級分組 分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,"當(dāng)前溫度為");
- 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);
- }
- }
復(fù)制代碼
所有資料51hei提供下載:
可調(diào)時鐘加溫度顯示.rar
(327.7 KB, 下載次數(shù): 45)
2018-8-12 14:28 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
評分
-
查看全部評分
|