Adresářová struktura pro odevzdání soutěžních úloh.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

42 lines
670B

  1. #include <Wire.h>
  2. #include <BH1750.h>
  3. #define ledka D0
  4. BH1750 lightMeter;
  5. void setup(){
  6. Serial.begin(9600);
  7. pinMode(ledka, OUTPUT);
  8. // Initialize the I2C bus (BH1750 library doesn't do this automatically)
  9. Wire.begin();
  10. // On esp8266 you can select SCL and SDA pins using Wire.begin(D4, D3);
  11. lightMeter.begin();
  12. Serial.println(F("BH1750 Test begin"));
  13. }
  14. void loop() {
  15. float lux = lightMeter.readLightLevel();
  16. Serial.print("Light: ");
  17. Serial.print(lux);
  18. Serial.println(" lx");
  19. if(lux < 200)
  20. {
  21. digitalWrite(ledka, HIGH);
  22. }
  23. else
  24. {
  25. digitalWrite(ledka, LOW);
  26. }
  27. delay(1000);
  28. }