单片机源程序如下:
- #include <stm32f10x.h>
- #include <stdio.h>
- #include "usart.h"
- #include "string.h"
- #include "led.h"
- #include "sys.h"
- #include "oled.h"
- #include "delay.h"
- #include "bmp.h"
- #include "dht11.h"
- char usart1_buf[BUF_SIZE]; // 串口1接收数据数组
- char usart1_index; // 串口1接收数据下标(长度)
- char usart1_flag; // 串口1接收完毕标志(是:1 否:0)
- int main (void)
- {
- // 初始化硬件函数调用
- u8 temp;
- u8 humi;
-
- Init_USART1(); // 串口初始化,9600
- Init_LED();
- Delay_init();
- OLED_Init();
-
- while(1)
- {
-
-
- OLED_Refresh();
-
- DHT11_Read_Data(&temp,&humi);//
-
- OLED_ShowChinese(0,0,0,16,1);//
- OLED_ShowChinese(18,0,1,16,1);//
- OLED_ShowChar(36,0,':',16,1);//显示ASCII字符
- /*OLED_ShowChinese(54,0,2,16,1);//
- OLED_ShowChinese(72,0,3,16,1);//
- OLED_ShowChinese(90,0,4,16,1);//
- */
-
- OLED_ShowChinese(0,16,5,16,1);//
- OLED_ShowChinese(18,16,6,16,1);//
- OLED_ShowChar(32,16,':',16,1);//显示ASCII字符
- OLED_ShowNum(50,16,temp,2,16,1);
- OLED_ShowChinese(68,16,9,16,1);//
-
-
- OLED_ShowChinese(0,32,7,16,1);//
- OLED_ShowChinese(18,32,8,16,1);//
- OLED_ShowChar(32,32,':',16,1);//显示ASCII字符
- OLED_ShowNum(48,32,humi,2,16,1);
- OLED_ShowChar(66,32,'%',16,1);//显示ASCII字符
- }
-
- }
复制代码
代码下载:
代码.7z
(340.67 KB, 下载次数: 323)
|