LCD + BH1750 Bar Graph

IMG_1419

This sketch requires LcdBarGraph and BH1750 library.

You can download the library here

https://docs.google.com/file/d/0B4qM0hq-OmC1RHhEcXRNSmZ1YW8/

#include <LiquidCrystal.h>
#include <LcdBarGraph.h>
#include <Wire.h>
#include <BH1750.h>

BH1750 lightMeter;

byte lcdNumCols = 16; // — number of columns in the LCD
byte sensorPin = 2; // — value for this example

LiquidCrystal lcd(8,9,10,11,12,13); // — creating LCD instance
LcdBarGraph lbg(&lcd, lcdNumCols);// — creating a 4 char wide baraph in the end of second column (column 1)

void setup(){
// — initializing the LCD
lcd.begin(2, lcdNumCols);
lcd.clear();
lightMeter.begin();
// — do some delay: some time I’ve got broken visualization
delay(100);

}

void loop()
{
uint16_t lux = lightMeter.readLightLevel();
// — draw bar graph from the analog value readed
lbg.drawValue((lux), 30);
// — do some delay: frequent draw may cause broken visualization
delay(100);
}

Advertisements
This entry was posted in Arduino Project. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s