Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. /*
  2. This is a simple code to test BH1750FVI Light senosr
  3. communicate using I2C Protocol
  4. this library enable 2 slave device address
  5. Main address 0x23
  6. secondary address 0x5C
  7. connect this sensor as following :
  8. VCC >>> 3.3V
  9. SDA >>> A4
  10. SCL >>> A5
  11. addr >> A3
  12. Gnd >>>Gnd
  13.  
  14. Written By : Mohannad Rawashdeh
  15.  
  16. */
  17.  
  18. // First define the library :
  19. #include <BH1750FVI.h> // Sensor Library
  20. #include <Wire.h> // I2C Library
  21. #include <LiquidCrystal.h>
  22.  
  23. LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
  24. uint16_t Light_Intensity=0;
  25. // Call the function
  26.  
  27. BH1750FVI LightSensor;
  28.  
  29.  
  30. void setup() {
  31. // put your setup code here, to run once:
  32. Serial.begin(9600);
  33. lcd.begin(16, 2);
  34.  
  35. // call begin Function so turn the sensor On .
  36. LightSensor.begin();
  37. LightSensor.SetAddress(Device_Address_H); //Address 0x5C
  38. LightSensor.SetMode(Continuous_H_resolution_Mode);
  39. lcd.setCursor(0, 0);
  40. lcd.print("BH1750 Sensor");
  41. lcd.setCursor(1, 1);
  42. lcd.print("Please wait...");
  43. delay(3000);
  44. lcd.clear();
  45.  
  46. }
  47.  
  48. void loop() {
  49. // put your main code here, to run repeatedly:
  50. lcd.clear();
  51. lcd.setCursor(0, 0);
  52. lcd.print(" Intensity = ");
  53. lcd.setCursor(5, 1);
  54. Light_Intensity = LightSensor.GetLightIntensity();
  55. lcd.print(Light_Intensity);
  56. lcd.print(" Lux");
  57. delay(2000);
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement