add BH1750 sensor example
This commit is contained in:
parent
944f1b06d6
commit
a95b0c9d46
18 changed files with 1140 additions and 0 deletions
|
@ -0,0 +1,23 @@
|
|||
#include <Wire.h>
|
||||
#include <BH1750FVI.h>
|
||||
|
||||
BH1750FVI eye;
|
||||
word maxLux = 0;
|
||||
|
||||
void setup() {
|
||||
Wire.begin();
|
||||
Serial.begin(115200);
|
||||
//most basic setup with all default options
|
||||
eye.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//take a sensor reading, with units of Lux
|
||||
word value = eye.getLightLevel();
|
||||
byte spaces;
|
||||
if(value>maxLux) maxLux=value;
|
||||
spaces=map(value, 0, maxLux, 0, 32);
|
||||
for(int i=0; i<spaces; i++) Serial.print(' ');
|
||||
Serial.println(value);
|
||||
delay(100);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue