I attached the schematic of my project. With original code everything works Great.
I need to change only one thing - Relays must do PULSE instead of CONSTANTLY ON/CONSTANTLY OFF
so, for example i changed the code of LIGHT control:
// control hood based on 'light' and 'ventilation' variables
void controlHood() {
bool logLight = light!=last_light;
bool logVent = ventilation!=last_ventilation;
// control light
switch (light) {
// Light OFF
case 0:
if (logLight) Serial.println("Light: OFF");
digitalWrite(PIN_OUT_LIGHT, ON);
delay(1000);
digitalWrite(PIN_OUT_LIGHT, OFF);
delay(1000);
break;
// Light ON
case 1:
if (logLight) Serial.println("Light: ON");
digitalWrite(PIN_OUT_LIGHT, ON);
delay(1000);
digitalWrite(PIN_OUT_LIGHT, OFF);
delay(1000);
break;
default:
break;
}
But the code is gone mad. Insted of simply make ON - 1sec Delay - OFF it makes it 2-3 times. But worst part is that suddenly it makes it every time it receives other codes - when I send VENTILATION 1 signal it firstly make 2-3 times LIGHT ON/OFF and then VENTILATION 1.
