[solved - reassigned V pins] MKR1000 menu widget compiling problems

Hi,

I built a project 2 weeks back with an Arduino MKR1000 (started 9th March, last update was the 15th), and uncovered it again today to test, but the code now won’t compile. There’s a problem with virtual pin 4, which is connected to a menu widget; I assume a new update changes how they work, but I can’t see how from the documentation (online and in the app). Blynk library version 0.4.6 is installed.

Is this something I can fix in the code or should I do something like reinstall the library?

Error feedback is:

D:\Documents\Arduino\Mar9_BlynkFinalProject\Mar9_BlynkFinalProject.ino: In function 'void BlynkWidgetWrite4(BlynkReq&, const BlynkParam&)':

D:\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkHandlers.h:155:10: error: redefinition of 'void BlynkWidgetWrite4(BlynkReq&, const BlynkParam&)'

     void BlynkWidgetWrite ## pin (BlynkReq BLYNK_UNUSED &request, const BlynkParam BLYNK_UNUSED &param)
          ^
D:\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkHandlers.h:163:31: note: in expansion of macro 'BLYNK_WRITE_2'

 #define BLYNK_WRITE(pin)      BLYNK_WRITE_2(pin)
                               ^
D:\Documents\Arduino\Mar9_BlynkFinalProject\Mar9_BlynkFinalProject.ino:236:1: note: in expansion of macro 'BLYNK_WRITE'

 BLYNK_WRITE(V4)
 ^
D:\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkHandlers.h:155:10: error: 'void BlynkWidgetWrite4(BlynkReq&, const BlynkParam&)' previously defined here

     void BlynkWidgetWrite ## pin (BlynkReq BLYNK_UNUSED &request, const BlynkParam BLYNK_UNUSED &param)
          ^
D:\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkHandlers.h:163:31: note: in expansion of macro 'BLYNK_WRITE_2'

 #define BLYNK_WRITE(pin)      BLYNK_WRITE_2(pin)
                               ^
D:\Documents\Arduino\Mar9_BlynkFinalProject\Mar9_BlynkFinalProject.ino:186:1: note: in expansion of macro 'BLYNK_WRITE'

The menu code seems right, from the documentation

BLYNK_WRITE(V4)
{
  switch (param.asInt())
  {
    case 1:
    {
     Serial.println("System is now off.");
     //logic 1
     break;
    }
    case 2:
    {
     Serial.println("Eco mode selected");
     //logic 2
     break;
    }
    case 3:
    {
     Serial.println("Fast mode selected");
     //logic 3
     break;
    }
    case 4:
    {
     Serial.println("Custom mode selected. Slider can now be moved");
     //logic 4
     break;
    }
  }
}

Thank you in advance!

I sometimes find these errors misleading… Can you post the whole code so I (or someone else) can try to compile it and compare errors. Thanks

Most probably you assigned several Write handlers for the same V4 pin

1 Like

Ah. Sorry, stupid mistake - I’d assigned V4 to both a menu and a step widget. Thank you @vshymanskyy, good pointer :flushed: