平台:Arduino
IDE:Arduino 1.6.7
BH1750FVI模块,基于IIC总线
程序模块流程描述:
1.驱动BH1750FVI,将获得的数据转化为整数型并存储(单位LX)
2.通过算法将LX转为EV值
3.构建光圈表和快门速度表,对照EV表进行查询
4.得到最合适的快门速度,依据ISO进行偏移,得到在对应光圈,ISO和光强下最终的快门速度(结果)
//主函数文件,包括了对BH1750的声明,测试平台为Arduino UNO,IIC接口为A4,A5.
//Base on BH1750 sensor modle
#include //IIC
#include
int BH1750address = 0x23;
byte buff[2];
void setup()
{
}
void loop()//MyBlgo:http://blog.sina.com.cn/u/3909624897, if you have some question
{
}
int BH1750_Read(int address) //
{
}
void BH1750_Init(int address)
{
}
//测光表函数文件,包含有转换EV数值,进行快门-光圈-EV表格筛选等函数
int H, E, T; //H = E x T;E = I x T;
const int ISO[10] ={100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600};
int Iris , SpeedM = 0, R = 2 , M=0, I=1;//R is iris area number,M is speed area number,I is is number ,default is ISO 100
int Elux;//AS the balance reference of expose and lux;
float EV;
int i,j;//MyBlgo:http://blog.sina.com.cn/u/3909624897, if you have some question
int EVSeries[14][11] = {//The matrix of EV,x is iris num,y is shutter speed num
float IrisR[11] = {1.0, 1.4, 2.0, 2.8, 4.0, 5.6, 8.0, 11.0, 16.0, 22.0, 32.0};
int Speed[14] = { 8000, 4000, 2000, 1000, 500, 250, 125, 60, 30, 15, 8, 4, 2 , 1 };
int CankaoLUX[18] = {2.5, 5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480, 40960, 81920, 163840};
{
}
void EVandIrisToCountOutSpeed
{
}
void SerialPrint()
{
}