Advertisement
MELAMOURI

Untitled

May 29th, 2023
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <BH1750.h>
  3. #include <LiquidCrystal_I2C.h>
  4.  
  5. BH1750 lightMeter;
  6. LiquidCrystal_I2C lcd(0x27, 16, 2);
  7.  
  8. void setup() {
  9.   Wire.begin();
  10.   lightMeter.begin();
  11.   lcd.begin();
  12.   lcd.backlight();
  13.   lcd.setCursor(0, 0);
  14.   lcd.print("BH1750 Test");
  15.   lcd.setCursor(0, 1);
  16.   lcd.print("Please wait...");
  17.   delay(3000);
  18.   lcd.clear();
  19. }
  20.  
  21. void loop() {
  22.   lcd.clear();
  23.   lcd.setCursor(0, 0);
  24.   lcd.print("Light Intensity ");
  25.   lcd.setCursor(5, 1);
  26.   float lux = lightMeter.readLightLevel();
  27.   lcd.print(lux);
  28.   lcd.print(" Lux");
  29.   delay(2000);
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement