I found the initial code and library here:
http://www.instructables.com/id/BH1750- ... ht-Sensor/
https://github.com/Genotronex/BH1750FVI_Master
Once you have downloaded the library just open the Arduino IDE and the example code will be there for the basic examples. I went ahead and modded the eample code for my Nokia 5110 LCD display. Here is the code to make your own with LCD
Take the code, make it better!
Cheers
/*
This code is for the BHT1750 Light Sensor (provided to me by ICstation.com)
This is a work in progress but hopefully it will help someone else by providing
a base to start and work from.
Please check out my Youtube videos here and consider a thumbs up if this helped you!
Youtube : http://www.youtube.com/user/Shadow5549
Website, Forum and store are at http://mkme.org
I2C Connections:
SDA connected to pin Analog 4
SCL connected to pin Analog 5
addr >> A3
Gnd >>>Gnd
Pin 11 for contrast on the Nokia 5110
*/
#include "Adafruit_GFX.h"
#include "Adafruit_PCD8544.h"
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);//4 and 3 are reversed on the cheap eBay models
#include <BH1750FVI.h> // Sensor Library
#include <Wire.h> // I2C Library
uint16_t Light_Intensity=0;
BH1750FVI LightSensor;
void setup() {
Serial.begin(9600);
analogWrite(11,220);// PWM of LCD backlight but ebay unit is backwards-
//must go high + cycle to dim
//Very Dim=230
LightSensor.begin();
LightSensor.SetAddress(Device_Address_H); //Address 0x5C
LightSensor.SetMode(Continuous_H_resolution_Mode);
Serial.println("Running...");
display.begin();//Display code
display.setContrast(50);//Nokia 5110 works best at 50- no more flicker
delay(1000);
display.clearDisplay(); // clears the screen and buffer
display.setTextSize(1); // set text size
display.setTextColor(BLACK);
//delay(1000);
// Splash Personal- taken from example code
display.setTextSize(1);
display.setTextColor(BLACK);
display.setCursor(0,0);
display.println(" Eric's");
display.println("");
display.println(" BH1750");
display.println(" Light");
display.println(" Sensor");
display.display();
delay(2000);
display.clearDisplay(); // clears the screen and buffer
}
void loop() {
display.clearDisplay(); // clears the screen and buffer
display.setCursor(0,0);
display.println(" Intensity = ");
//display.setCursor(5, 1);
display.println ("");
Light_Intensity = LightSensor.GetLightIntensity();
display.setTextSize(2); // set text size
display.println(Light_Intensity);
display.setTextSize(1);
Serial.print (Light_Intensity);//for troubleshooting
display.println(" Lux");
display.display();
//delay(2000);
}