找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2512|回复: 0
收起左侧

STM32 C8T6 OLED+DHT11+超声波+bh1750光照传感器+ADC角度测量

[复制链接]
ID:958854 发表于 2021-9-26 08:09 | 显示全部楼层 |阅读模式
文件中包含了OLED+DHT11+超声波+bh1750光照传感器+ADC角度测量的程序
是我初学嵌入式的时候写的 里面有相关的注释 给大家分享下
单片机源程序如下:
  1. #include "main.h"
  2. #include "stm32f10x.h"
  3. #include "stdio.h"
  4. #include "my_adc.h"
  5. #include "adc2.h"
  6. #include "my_time.h"
  7. #include "my_gpio.h"
  8. #include "stm32f10x_usart.h"
  9. #include "public.h"
  10. #include "my_uart.h"
  11. #include "Lcd_f.h"
  12. #include "my_oled.h"
  13. #include "bmp.h"        
  14. #include "bh1750.h"
  15. #include "Ultrasonic.h"
  16. #include "my_pwm.h"
  17. #include "my_dht11.h"
  18. /*
  19. GPIO : OLED(I2C)时钟PA0 数据PA1 对应文件 my_oled
  20.        基准电压测量 PA3接测量电压 对应文件 adc2
  21.                          角度测量 PA2接角度传感器输出叫 对应文件 my_adc
  22.                          光照 时钟接PA4 数据接PA5 ADDR接低或空着 对应文件 bh1750
  23.                          超声波测距 TRIG接B12 Echo接B13 对应文件 Ultrasonic

  24.        文件中一般都注释过了
  25. */
  26. int main()
  27. {
  28.   float Light_intensity;        
  29.         TIMER2_init(999,71);
  30.         TIMER3_init(899,0);
  31.         TIMER4_init(499,7199);//20ms
  32.         pwm_init();
  33.         Ultrasonic_init();
  34.   adc_init();        
  35.          adc2_init();                          //ADC初始化
  36.         GPIOA_init();
  37.         GPIOB_init();
  38.         GPIOC_init();
  39.         Init_BH1750();
  40.         OLED_Init();                        //初始化OLED  
  41.         OLED_Clear();
  42.         NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断优先级分组为组2
  43.         OLED_DrawBMP(0,0,128,8,BMP1);
  44.         delay_ms(1000);
  45.         OLED_Clear();
  46.         time_buzzer=5;
  47.         
  48.         while(1)
  49.         {
  50.                 Light_intensity=read_BH1750();
  51.                 OLED_ADC_hs();
  52.                 OLED_ADC2_hs();
  53.                 oled_Light_intensity(Light_intensity);
  54.                 oled_Ultrasonic();
  55.                 DHT11_data_oled();
  56.         }
  57.         
  58. }
复制代码

本人初学,仅供参考,如有错误,请大家回帖多多指教,代码下载::
C8T6_V1.0.8.7z (238.61 KB, 下载次数: 140)

评分

参与人数 1黑币 +30 收起 理由
admin + 30 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表