Menu widget and if

Hi all,
I’m quite loss with the menu widget. Example I found are pretty small and I can’t fix this problem.

GOAL
make a choice in the menu and, take this choice in consideration during a button action.

Example:
I want create a super remote control able to control all HI-FI stuff in my house.
If I select from the menu (V1) LivingRoom TV and press the ON/OFF button (V2) Blynk have to send the proper IR code.

Actually I’m loss with the code where:

int pinValueV1; //this is reading the V1 (menu input) ...i got 4 cases 1,2,3,4

//===========MENU

BLYNK_WRITE(V2) // ON/OFF
{
   if(param.asInt() && (pinValueV1 =="1" )){  // assigning incoming value from pin V20 to a variable
   irsend.sendNEC(0xFB38C7,32); // ON
    }else {
       //LOW - OFF
    }
        
}

I would like to see the cases.

here we are with the full code:

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
// IR remote
#include <IRremoteESP8266.h>

char auth[] = "XXXX";


 
SimpleTimer timer;

IRsend irsend(0); ///an IR led is connected to GPIO --> D4



//===========MENU
int pinValueV1;

BLYNK_WRITE(V1) {
  switch (param.asInt())
  {
    case 1: // Item 1 - TV LIVING
      Blynk.virtualWrite(V1, "1");
      break;
    case 2: // Item 2 - DVD
      Blynk.virtualWrite(V1, "2");
      break;
    case 3: // Item 3 - AUX
      Blynk.virtualWrite(V1, "3");
      break;
  }
}



BLYNK_WRITE(V2) // ON/OFF
{
   if(param.asInt() && (pinValueV1 =="1" )){  // assigning incoming value from pin V20 to a variable
   irsend.sendNEC(0xFB38C7,32); // ON
    }else {
       //LOW - OFF
    }
        
}
        
// ========LOOP
void setup()
{
  Serial.begin(9600);
  irsend.begin(); 
  Blynk.begin(auth, "AndroidAPbosisio", "X");
 //Blynk.begin(auth, "NETGEAR41", "X");
Blynk.syncAll();
}

void loop()
{  
  Blynk.run();

 }

I believe V2 is your Blynk button but you have a comment about V20 that doesn’t appear anywhere.

Not sure why you are using the menu to try and send a String to the menu.

Just change to

Blynk.virtualWrite(V1, "1");

to

pinValueV1 = 1;

You have defined it as an integer so in V2 you can’t use “1” in the if statement, simply 1.

You need code for options 2 and 3 of the menu and they need changing like option 1.

Hi Costas, ops sorry for V20…it’s an error.
I made all changes you proposed and now code is this, but it seems there is some errors (I’ve posted errors after the code)

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
// IR remote
#include <IRremoteESP8266.h>

char auth[] = "XXXX";


 
SimpleTimer timer;

IRsend irsend(0); ///an IR led is connected to GPIO --> D4



//===========MENU
int pinValueV1;

BLYNK_WRITE(V1) {
  switch (param.asInt())
  {
    case 1: // Item 1 - TV LIVING
      pinValueV1 = 1;
      break;
    case 2: // Item 2 - DVD
      pinValueV1 = 2;
      break;
    case 3: // Item 3 - AUX
      pinValueV1 = 3;
      break;
  }
}



BLYNK_WRITE(V2) // ON/OFF
{
   if(param.asInt() && (pinValueV1 =="1" )){  
   irsend.sendNEC(0xFB38C7,32); // ON on TV Living 
    }
    
    else if (param.asInt() && (pinValueV1 =="2" )){  
   irsend.sendNEC(0xFB38C1,32); // ON on DVD
    }

    else if (param.asInt() && (pinValueV1 =="3" )){  
   irsend.sendNEC(0xFB28C1,32); // ON on AUX
    }
        
}
        
// ========LOOP
void setup()
{
  Serial.begin(9600);
  irsend.begin(); 
  Blynk.begin(auth, "AndroidAPbosisio", "X");
 //Blynk.begin(auth, "NETGEAR41", "X");
Blynk.syncAll();
}

void loop()
{  
  Blynk.run();

 }

sketch_jan25a-testconmenu/sketch_jan25a-testconmenu.ino: In function ‘void BlynkWidgetWrite2(BlynkReq&, const BlynkParam&)’:
sketch_jan25a-testconmenu:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
if(param.asInt() && (pinValueV1 ==“1” )){
^
sketch_jan25a-testconmenu:45: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
else if (param.asInt() && (pinValueV1 ==“2” )){
^
sketch_jan25a-testconmenu:49: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
else if (param.asInt() && (pinValueV1 ==“3” )){
^
exit status 1
ISO C++ forbids comparison between pointer and integer [-fpermissive]

How to fix it? thank you for your support.

Fix is included in my last post.

Strange syntax on these lines:

if(param.asInt() && (pinValueV1 == "1" )){  

should be… remove the extra ()'s and ""s

if( param.asInt() && pinValueV1 == 1 ){  

Hi Jamin and Costas,
i just tested the code with the proposed fixed and works fine. Thank you again.
Problem solved