#include "hp_BH1750.h"
hp_BH1750 BH1750;
int LED = 7;
int SchwelleDunkelheit = 100;
void setup()
{
pinMode (LED, OUTPUT);
Serial.begin(9600);
delay(1000);
// Sensor starten
if (!BH1750.begin(0x23))
{
Serial.println("BH1750 Sensor nicht gefunden!");
while(1);
}
else Serial.println("BH1750 Sensor gefunden!");
/*
setQuality
BH1750_QUALITY_LOW
BH1750_QUALITY_HIGH
BH1750_QUALITY_HIGH2
*/
BH1750.setQuality(BH1750_QUALITY_HIGH2);
}
void loop()
{
BH1750.start();
float Helligkeit = BH1750.getLux();
Serial.println("Helligkeit: " + String(Helligkeit));
if (Helligkeit < SchwelleDunkelheit) digitalWrite(LED, HIGH);
else digitalWrite(LED, LOW);
delay(500);
}
Letzte Aktualisierung: