代码拉取完成,页面将自动刷新
#include <Wire.h>
#include <math.h>
#include <Arduino.h>
//#include <MsTimer2.h>
#define SDA_PIN 21
#define SCL_PIN 22
int BH1750address = 0x23;//BH1750 I2C地址0x23 //ADDR="L" for this module
int BH1750() //BH1750设备操作
{
unsigned char buff[2];
int i=0;
double val=0;
//开始I2C读写操作
Wire.beginTransmission(BH1750address);
Wire.write(0x10);//1lx reolution 120ms//发送命令
Wire.endTransmission();
delay(200);
//读取数据
// Wire.beginTransmission(BH1750address);
//delay(120);
Wire.requestFrom(BH1750address, 2);
while(Wire.available())
{
// Serial.println("2");
buff[i] = Wire.read(); // receive one byte
i++;
}
Wire.endTransmission();
if(2==i)
{
val=((buff[0]<<8)|buff[1])/1.2;
}
return val;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。