Hello to all (excuse my english google translate)
I can not understand where I’m wrong …
I am creating an alarm system for my house, to activate or deactivate the system using an RFID reader and even Blynk of course !.
I wrote two functions and are called to time with the library SimpleTimer, one turns on and off with a button on Blynk and the other turns on and off with the RFID tag. Used together can not make them work.
Are so simplified:
button widget virtual pin5
////////////////////// LOGIC BLYNK/////////////////////////////
BLYNK_CONNECTED() { if (isFirstConnect) { Blynk.syncAll(); } }
BLYNK_WRITE(V5){ button = param.asInt(); }
void logicaBLYNK(){
if ((button == HIGH)&&(stateAllarm == 0)) {
Serial.println(“allarm on”);
activateAllarm();
} else if ((button == LOW)&&(stateAllarm == 1)) {
Serial.println(“allarm off”);
deactivateAllarm();
}
}
////////////////////////////// LOGIC RFID/////////////////////////////
if (((tag1== codeRead)||(tag2 == codeRead))&&(stateAllarm == 0)) { Blynk.virtualWrite(V5, HIGH); Serial.println("allarm on"); activateAllarm(); } else if (((tag1 == codeRead)||(tag2 == codeRead))&&(stateAllarm == 1)) { Blynk.virtualWrite(V5, LOW); Serial.println("allarm off"); deactivateAllarm(); } }
with this code if I use Blynk smartphone works ok, but if such active with RFID tags alarm alarm turns on and turns off immediately.
Example: active RFID tags with alarm, is activated, then run the “logicaBLYNK” and located in the LOW and then immediately off the alarm button was.
When enabled with RFID tag performs “Blynk.virtualWrite (V5, HIGH);” because then you see the state LOW?
On smatrphone Blynk you see that the button that lights up / lights but the state remains LOW? changes state only if it is pressed from the phone app …
what I did not understand? sorry but I’m a beginner …
Thanks bye