Kart31 I hope you can excuse a little thread drift...
Yeah, they are real easy to use. Here is some Arduweenie sample code (if I copied the right file):
Code:
#include <Wire.h>
#define BYTES2READ (2)
#define BH1750addr (0x23) /* slave I2c address */
/* globals */
int status;
void setup() {
Wire.begin();
Serial.begin(9600);
Serial.println("BH1750 sensor test");
status = initBH1750();
if (status) {
Serial.print("Error ");
Serial.print(status);
Serial.println("Could not write BH1750 mode");
}
}
void loop() {
byte BHlxdata[2]; /* data read from the sensor */
byte lux; /* converted lux value */
/* read the sensor data */
Wire.requestFrom(BH1750addr, 2);
BHlxdata[0] = (byte)Wire.read();
BHlxdata[1] = (byte)Wire.read();
/* translate the data */
lux = ((BHlxdata[0] << 8) | BHlxdata[1]) / 1.2;
Serial.print(lux);
Serial.println(" lux");
/* wait 120 ms before the next read as per BH1750 data sheet */
delay(120);
/* delay for the loop print - change as desired */
delay(1500);
}
byte initBH1750()
{
byte BHmodedata = 0x10; /* BH1750 initialization code for 1 lux resolution */
Wire.beginTransmission(BH1750addr);
Wire.write(BHmodedata);
if ( (status = Wire.endTransmission() ) ) {
Serial.print("Error ");
Serial.print(status);
Serial.println("Could not write BH1750 mode");
}
delay(180); /* 180 ms delay as per BH1750 data sheet */
return (status);
}
About 5 years ago, I used one to figure out the resistors to use (to aim for equal intensity) on an RGB led for a color mixer using a pic 12F1572. Was not smart enough to do it with math so I did it like this:
View attachment 122672
I used the values shown on the dashed horizontal for the respective R-G-B elements. Empirically, it worked and I was real proud of myself. After about 10 minutes of staring, I started to see spots and was less proud