找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 2308|回復(fù): 0
收起左側(cè)

STM32瓦斯報(bào)警程序 mq2+bmp280+ds18b20+oled

[復(fù)制鏈接]
ID:277134 發(fā)表于 2021-6-15 19:16 | 顯示全部樓層 |閱讀模式
stm32驅(qū)動(dòng)mq2和bmp280和ds18b20和oled的瓦斯報(bào)警系統(tǒng)

單片機(jī)源程序如下:
  1. #include "bsp.h"
  2. #include "stdio.h"
  3. #include "stm32f10x.h"
  4. #include "systick.h"
  5. #include "LED.h"
  6. #include "USART.h"
  7. #include "DS18B20.h"
  8. #include "oled.h"
  9. #include "sys.h"
  10. #include "adc.h"
  11. #include "beep.h"
  12. #include "myiic.h"
  13. #include "bme280.h"
  14. float Temp;
  15. float bmp280_temp;
  16. float bmp280_press;
  17. float bmp280_humi;
  18. float high;
  19. int main(){
  20.         OLED_Init();
  21.         BEEP_Init();
  22.   Adc_Init();        
  23.         delay_init();
  24.         USART1_Init();
  25.         LED_Init();
  26.         delay_ms(1000);
  27.         while(!Ds18b20_Init());

  28.         while(1){
  29. //        bme280GetData(&bmp280_press,&bmp280_temp,&bmp280_humi,&high);
  30.         LED_Turn();
  31.         Temp=Ds18b20ReadTemp();
  32. //        printf("temp:%2.4f\r\n",Temp*0.0625);
  33.         OLED_Num5(0,1,Get_Adc_Average(ADC_Channel_1,10));
  34.   OLED_Num5(0,0,Temp*0.0625);
  35.         delay_ms(1000);
  36.         }
  37.         
  38. }
復(fù)制代碼

所有代碼51hei下載,如有錯(cuò)誤請(qǐng)大家多多指教:
UART+DS18B20.7z (211.7 KB, 下載次數(shù): 108)

評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表