Else without a previous If

I get a strange error " else without a previous if " to this statement can anybody explain why?

BLYNK_WRITE(V13)
{
  BTNsave = param.asInt();
  if (BTNmode == 0);
  {
    if (BTNsave == 1)
    {
      EEPROMWritelong(0, maxPWM1);
      Blynk.virtualWrite(V15, maxPWM1);
      timer.setTimeout(2000L, []()
      {
        svPWM1 = EEPROMReadlong(0);
        Test2.virtualWrite(V55, svPWM1);
        Blynk.virtualWrite(V12, 1);
        Blynk.virtualWrite(V13, 0);
        Serial.print("svPWM1 :");
        Serial.println(svPWM1);
        BTNmode = 1;
      });
    }
  }
  else
  {
    Blynk.virtualWrite(V13, 0);
  }
}

Looks a bit suspicious!

Pete.

That’s part the end of the lambda timer

It’s the last ; in

if (BTNmode == 0);
1 Like

Ahhh…thanks. I swear I have been looking at that piece of code for hours and did not see that. Sometimes a fresh pair of eyes is needed

That’s why sometimes a walk with a sip of coffee will help :wink:

2 Likes

A bit hard at moment with lockdown. Keep well thanks

1 Like