Created
July 15, 2016 16:07
-
-
Save houmei/60255efe8029ca7a79e51a9c698a34ab to your computer and use it in GitHub Desktop.
GY302module(BH1750FVI) lux meter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* GY-302(BH1750FVI) test | |
Library: https://cmosgr.wordpress.com/2013/09/02/bh1750fvi-gy-302-light-sensor-module/ | |
ADDR - A3(GND) | |
SDA - SDA(A4) | |
SCL - SCL(A5) | |
GND | |
VCC | |
*/ | |
#include <Wire.h> | |
#include <BH1750.h> | |
BH1750 lightMeter; | |
void setup(){ | |
pinMode(A3,OUTPUT); digitalWrite(A3,0); | |
Serial.begin(9600); | |
lightMeter.begin(); | |
Serial.println("Running…"); | |
} | |
void loop() { | |
uint16_t lux = lightMeter.readLightLevel(); | |
Serial.print("Light: "); | |
Serial.print(lux); | |
Serial.println(" lx"); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment