Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2.  
  3. //http://agpminiprojects.blogspot.com.es/
  4.  
  5. // Librerias
  6.  
  7. #include <BH1750FVI.h> // Sensor
  8. #include <Wire.h> // I2C
  9. #include <LCD.h>
  10. #include <LiquidCrystal_I2C.h>
  11.  
  12. //Funcion de configuracion de pines del modulo LCD/I2C
  13.  
  14. #define I2C_ADDR 0x3F // <<----- Agregue su dirección aquí. Buscar desde I2C Scanner
  15. #define BACKLIGHT_PIN 3
  16. #define En_pin 2
  17. #define Rw_pin 1
  18. #define Rs_pin 0
  19. #define D4_pin 4
  20. #define D5_pin 5
  21. #define D6_pin 6
  22. #define D7_pin 7
  23.  
  24. LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
  25.  
  26. uint16_t Light_Intensity=0;
  27.  
  28. BH1750FVI LightSensor;
  29.  
  30.  
  31. void setup() {
  32.  
  33. lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  34. lcd.begin(16, 2);
  35. lcd.setCursor(0, 0); // (colunna, fila)
  36. lcd.print (" LUXOMETRO");
  37. lcd.setCursor(0, 1);
  38. lcd.print ("Resolucion: 1LUX");
  39. delay(1500);
  40. lcd.clear();
  41. lcd.setCursor(0, 0);
  42. lcd.print ("http://agpminiprojects.blogspot.com.es/");
  43. lcd.setCursor(0, 1);
  44. lcd.print ("***************************************");
  45. delay(1000);
  46.  
  47. for (int positionCounter = 0; positionCounter < 22; positionCounter++) { // 22 veces
  48. lcd.scrollDisplayLeft(); // scroll una posicion a la izquierda
  49. delay(350);
  50. }
  51. delay(800);
  52.  
  53. lcd.clear();
  54. LightSensor.begin();
  55. LightSensor.SetAddress(Device_Address_H); //Address 0x5C
  56. LightSensor.SetMode(Continuous_H_resolution_Mode);
  57. lcd.print("Iniciando..");
  58. delay(500);
  59. lcd.print("..");
  60. delay(500);
  61. lcd.print("..");
  62. delay(500);
  63. lcd.setCursor(0, 1);
  64. lcd.print("Sensor BH1750");
  65. delay(2500);
  66. lcd.clear();
  67.  
  68.  
  69. }
  70.  
  71.  
  72. void loop()
  73.  
  74. {
  75. lcd.setCursor(0, 0);
  76. lcd.print("Iluminancia (E)=");
  77. lcd.setCursor(5, 1);
  78. Light_Intensity = LightSensor.GetLightIntensity();
  79. lcd.print(Light_Intensity);
  80. lcd.print(" ");
  81. lcd.setCursor(11, 1);
  82. lcd.print(" Lux");
  83. delay(1000);
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement