标题: bh1750光照模块的STM32源代码 [打印本页]

作者: 小胖波波    时间: 2018-4-22 21:07
标题: bh1750光照模块的STM32源代码
欢迎大家来使用

单片机源程序如下:
  1. #include "stm32f10x.h"
  2. #include "bsp_usart1.h"
  3. #include "bsp_i2c_gpio.h"
  4. #include "BH1750.h"
  5. #include "bsp_led.h"
  6. #include "bsp_GeneralTim.h"  
  7. #include "bsp_SysTick.h"
  8. #include "bsp_ili9341_lcd.h"
  9. #include "bsp_spi_flash.h"
  10. extern uint dis_data;
  11. extern uint date[4];
  12. float temp;
  13. int guang;

  14. extern uint ge,shi,bai,qian,wan;

  15. void Delay(__IO uint32_t nCount);         //简单的延时函数

  16. /**
  17.   * @brief  主函数
  18.   * @param  无
  19.   * @retval 无
  20.   */   
  21. int main(void)
  22. {
  23.   GPIOConfig();       //引脚初始化       
  24.         USART1_Config();         //串口初始化
  25.         Init_BH1750();     //光照模块初始化
  26.         printf("\r\n 这是一个I2C外设(AT24C02)读写测试例程 \r\n");
  27.        
  28.         Delay(72000000);         //简单的延时1S

  29.         while(1)
  30.         {
  31.         mread();      //连续读出bh1750内部数据,整理出date[0]为三次的平均值
  32. //        printf("\r\n  直接读取的数据为  %u \r\n  ",date[0]);
  33.                
  34. //        temp=(float)date[0]/1.2;
  35.                 temp=(float)(date[0]-21845)/89;
  36.         printf("\r\n  光照强度为:%.3f \r\n", temp);

  37.   Delay(36000000);         //简单的延时1s
  38.        
  39.                
  40.                

  41.         }
  42. }

  43. void Delay(__IO uint32_t nCount)         //简单的延时函数
  44. {
  45.         for(; nCount != 0; nCount--);
  46. }


  47. ……………………

  48. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:

光照2.rar (351.52 KB, 下载次数: 112)



作者: 你就做自己    时间: 2019-12-26 12:01
代码里有错误,在线求帮助,谢谢
作者: 星辰伴我同行    时间: 2021-11-4 13:28
有错误就不要放上来坑币啊





欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1