主函数代码
- #include "stm32f10x.h"
- #include "delay.h"
- #include "oled.h"
- #include "led.h"
- #include "dht11.h"
- int main(void) {
-
- u8 t=0;
- u8 temperature;
- u8 humidity;
-
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
-
- delay_init();
- LED_Init();
-
- OLED_Init();
- OLED_ShowString(0,0,"OLED INIT..",12);
-
- if(DHT11_Init()) //DHT113õê¼»ˉ
- {
- OLED_ShowString(0,12,"DHT11 ERROR",12);
- delay_ms(200);
- } else {
- OLED_ShowString(0,12,"DHT11 INIT..",12);
- delay_ms(200);
- }
- OLED_ShowString(0,24,"Run...",12);
- OLED_Refresh_Gram();
-
- while(1) {
- if(t%10==0)
- {
- if(!DHT11_Read_Data(&temperature,&humidity))
- {
- OLED_ShowChar(0,36,temperature,12,1);
- OLED_ShowChar(0,48,humidity,12,1);
- } else {
- OLED_ShowString(0,36,"READ DATE ERROR",12);
- }
- OLED_Refresh_Gram(); //¸üDÂÏÔê¾μ½OLEDÖD
-
- }
- delay_ms(10);
- t++;
- if(t==20)
- {
- t=0;
- LED0=!LED0;
- }
- };
- }
复制代码 |