stm32驱动mq2和bmp280和ds18b20和oled的瓦斯报警系统
单片机源程序如下:
- #include "bsp.h"
- #include "stdio.h"
- #include "stm32f10x.h"
- #include "systick.h"
- #include "LED.h"
- #include "USART.h"
- #include "DS18B20.h"
- #include "oled.h"
- #include "sys.h"
- #include "adc.h"
- #include "beep.h"
- #include "myiic.h"
- #include "bme280.h"
- float Temp;
- float bmp280_temp;
- float bmp280_press;
- float bmp280_humi;
- float high;
- int main(){
- OLED_Init();
- BEEP_Init();
- Adc_Init();
- delay_init();
- USART1_Init();
- LED_Init();
- delay_ms(1000);
- while(!Ds18b20_Init());
- while(1){
- // bme280GetData(&bmp280_press,&bmp280_temp,&bmp280_humi,&high);
- LED_Turn();
- Temp=Ds18b20ReadTemp();
- // printf("temp:%2.4f\r\n",Temp*0.0625);
- OLED_Num5(0,1,Get_Adc_Average(ADC_Channel_1,10));
- OLED_Num5(0,0,Temp*0.0625);
- delay_ms(1000);
- }
-
- }
复制代码
所有代码51hei下载,如有错误请大家多多指教:
UART+DS18B20.7z
(211.7 KB, 下载次数: 108)
|