Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <BH1750.h>
- BH1750 lightMeter;
- void setup() {
- //Serial.begin(9600);
- Serial.begin(115200);
- // Initialize the I2C bus (BH1750 library doesn't do this automatically)
- // On esp8266 devices you can select SCL and SDA pins using Wire.begin(D4, D3);
- Wire.begin();
- lightMeter.begin(BH1750::Mode::CONTINUOUS_HIGH_RES_MODE_2);
- Serial.println(F("BH1750 Test"));
- }
- int a = 0;
- int addto = 1;
- void loop() {
- //Serial.print("Light: ");
- Serial.println(lightMeter.readLightLevel());
- //Serial.print(" lx ");
- //Serial.println(a);
- a= a +addto;
- if(a == 254){addto = -1;}
- if(a == 0){addto = 1;}
- delay(140);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement