#include <LiquidCrystal_I2C.h>
#include <LED.h>
#include "Relay.h"
LED led(11);
Relay light(4, false); // constructor receives (pin, isNormallyOpen) true = Normally Open, false = Normally Closed
#define LDR_PIN 2
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup() {
led.begin(2000);
light.begin(); // inicializes the pin
pinMode(LDR_PIN, INPUT);
lcd.init();
lcd.backlight();
}
void loop() {
led.flash(LDR_PIN, 100);
lcd.setCursor(0, 0);
lcd.print("Turbidez: ");
if (digitalRead(LDR_PIN) == LOW) {
lcd.print("Limpa!");
light.turnOff(); //turns relay off
} else {
lcd.print("Suja ");
light.turnOn(); //turns relay on
bool isLightOn = light.getState(); //returns a bool, true = on, false = off
}
delay(100);
}