文件中包含了OLED+DHT11+超声波+bh1750光照传感器+ADC角度测量的程序
是我初学嵌入式的时候写的 里面有相关的注释 给大家分享下
单片机源程序如下:
- #include "main.h"
- #include "stm32f10x.h"
- #include "stdio.h"
- #include "my_adc.h"
- #include "adc2.h"
- #include "my_time.h"
- #include "my_gpio.h"
- #include "stm32f10x_usart.h"
- #include "public.h"
- #include "my_uart.h"
- #include "Lcd_f.h"
- #include "my_oled.h"
- #include "bmp.h"
- #include "bh1750.h"
- #include "Ultrasonic.h"
- #include "my_pwm.h"
- #include "my_dht11.h"
- /*
- GPIO : OLED(I2C)时钟PA0 数据PA1 对应文件 my_oled
- 基准电压测量 PA3接测量电压 对应文件 adc2
- 角度测量 PA2接角度传感器输出叫 对应文件 my_adc
- 光照 时钟接PA4 数据接PA5 ADDR接低或空着 对应文件 bh1750
- 超声波测距 TRIG接B12 Echo接B13 对应文件 Ultrasonic
- 文件中一般都注释过了
- */
- int main()
- {
- float Light_intensity;
- TIMER2_init(999,71);
- TIMER3_init(899,0);
- TIMER4_init(499,7199);//20ms
- pwm_init();
- Ultrasonic_init();
- adc_init();
- adc2_init(); //ADC初始化
- GPIOA_init();
- GPIOB_init();
- GPIOC_init();
- Init_BH1750();
- OLED_Init(); //初始化OLED
- OLED_Clear();
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断优先级分组为组2
- OLED_DrawBMP(0,0,128,8,BMP1);
- delay_ms(1000);
- OLED_Clear();
- time_buzzer=5;
-
- while(1)
- {
- Light_intensity=read_BH1750();
- OLED_ADC_hs();
- OLED_ADC2_hs();
- oled_Light_intensity(Light_intensity);
- oled_Ultrasonic();
- DHT11_data_oled();
- }
-
- }
复制代码
本人初学,仅供参考,如有错误,请大家回帖多多指教,代码下载::
C8T6_V1.0.8.7z
(238.61 KB, 下载次数: 140)
|