Bucle do while it doesn't work

when working with a virtual pin loop, the input works but when leaving it disconnects from blynk

BLYNK_WRITE(V1)
{
int Estado_Alarma = param.asInt();
if (Estado_Alarma == 0)
{
do
{
digitalWrite(13, HIGH);
}
while (Estado_Alarma != 0);
digitalWrite(13, LOW);
}
}

1 Like

I would not use a do while loop as it is blocking. Does the pi really need to be continuously set? Why not just the if statement?

1 Like
int Estado_Alarma;

timer.setInterval(2000L, EstadoAlarma );

void EstadoAlarma() {
if (Estado_Alarma == 0)
{
digitalWrite(13, HIGH);
}else{
digitalWrite(13, LOW);
}

BLYNK_WRITE(V1)
{
Estado_Alarma = param.asInt();
}
2 Likes

Excelent,
Thank you very much for the help

2 Likes

You are welcome :blush:

1 Like

You could also try:

BLYNK_WRITE(V1)
{
  digitalWrite(13, !param.asInt());
}
2 Likes

You are the best @JustBertC :scream::blush:

2 Likes