StackOverflow menu tab code

Hello, I’m trying to make a simple menu, where I choose a rate and it shows me certain values ​​according to what I chose, and triggers a link to an internet page.

Could someone guide me because after several menu choices the program crashes and overflow appears!?

APP:

Error:
Sin título

Thanks.

My CODE:

#define BLYNK_FIRMWARE_VERSION "0.1.0"

#define BLYNK_PRINT Serial

#define APP_DEBUG

#define USE_NODE_MCU_BOARD

#include "BlynkEdgent.h"

#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <EEPROM.h>
#include <WidgetRTC.h>

BlynkTimer timer;
WidgetRTC rtc;
WidgetLED led1(V6);
WidgetLED led2(V7);
WidgetLED led3(V17);
WidgetLED led4(V18);
WidgetLCD lcd(V36);

RF24 radio(D2, D8);  // CE, CSN
RF24Network network(radio);
const uint16_t this_node = 00;  // Address of this node in Octal format ( 04,031, etc)
const uint16_t node01 = 01;
const uint16_t node02 = 02;
const uint16_t node03 = 03;
const uint16_t node04 = 04;
const uint16_t node05 = 05;

float data[7];

#define EEPROM_SIZE 256

int ID1=0,ID2=0,ID3=0,ID4=0,ID5=0,ID6=0,ID7=0,ID8=0,ID9=0;

int BanderaSeleccionMenuArtefacto;

int flagSubsidio;

const int dirEnergiaT = 0;
int dirE1 = 10;
int dirE2 = 20;
int dirC1 = 30;
int dirC2 = 40;

float auxE1=0, auxE2=0, auxE3=0, auxE4=0, auxE5=0, Etotal=0;
float auxC1, auxC2, auxC3, auxC4, auxC5, auxCtotal;

int currentMenu; // Used to track which menu is in use
int MenuIndexID; // Used to track which menu item has been selected in the current menu
int Modo; 

BLYNK_WRITE(V32){//select from APP
  ID1=param.asInt();  
  if (ID1==1){
      flagSubsidio=1;    
  }
  else if (ID1==2){   
      flagSubsidio=2;
  }
  else if (ID1==3){
      flagSubsidio=3;
  }
}

BLYNK_WRITE(V40){//tab
  ID3=param.asInt();
 if (flagSubsidio==1){// BAJOS INGRESOS
  switch (ID3){
        case 1:{
          Blynk.virtualWrite(V33,0.01);//KWh estimado          
          Blynk.virtualWrite(V34,7);//KWh mes estimado
          Blynk.virtualWrite(V35,121); //costo estimado
        } 
        break;
        case 2:{
          Blynk.virtualWrite(V33,0.05);//KWh estimado          
          Blynk.virtualWrite(V34,37);//KWh mes estimado
          Blynk.virtualWrite(V35,299); //costo estimado   
        }
        break;
        case 3:{
          Blynk.virtualWrite(V33,0.08);//KWh estimado          
          Blynk.virtualWrite(V34,58);//KWh mes estimado
          Blynk.virtualWrite(V35,423); //costo estimado
        } 
        break;
        case 4:{
          Blynk.virtualWrite(V33,0.03);//KWh estimado          
          Blynk.virtualWrite(V34,22);//KWh mes estimado
          Blynk.virtualWrite(V35,210); //costo estimado
        }  
        break; 
        default:
        break;
     }        
  }
  else if (flagSubsidio==2){// MEDIOS INGRESOS
    switch (ID3){
        case 1:{
          Blynk.virtualWrite(V33,0.01);//KWh estimado          
          Blynk.virtualWrite(V34,7);//KWh mes estimado
          Blynk.virtualWrite(V35,121); //costo estimado
        } 
        break;
        case 2:{
          Blynk.virtualWrite(V33,0.05);//KWh estimado          
          Blynk.virtualWrite(V34,37);//KWh mes estimado
          Blynk.virtualWrite(V35,299); //costo estimado   
        }
        break;
        case 3:{
          Blynk.virtualWrite(V33,0.08);//KWh estimado          
          Blynk.virtualWrite(V34,58);//KWh mes estimado
          Blynk.virtualWrite(V35,423); //costo estimado
        } 
        break;
        case 4:{
          Blynk.virtualWrite(V33,0.03);//KWh estimado          
          Blynk.virtualWrite(V34,22);//KWh mes estimado
          Blynk.virtualWrite(V35,210); //costo estimado
        }  
        break; 
        default:
        break;
     }
  }
  else if (flagSubsidio==3){// MAYORES INGRESOS
      switch (ID3){
        case 1:{
          Blynk.virtualWrite(V33,0.01);//KWh estimado          
          Blynk.virtualWrite(V34,7);//KWh mes estimado
          Blynk.virtualWrite(V35,159); //costo estimado
        } 
        break;
        case 2:{
          Blynk.virtualWrite(V33,0.05);//KWh estimado          
          Blynk.virtualWrite(V34,37);//KWh mes estimado
          Blynk.virtualWrite(V35,501); //costo estimado   
        }
        break;
        case 3:{
          Blynk.virtualWrite(V33,0.08);//KWh estimado          
          Blynk.virtualWrite(V34,58);//KWh mes estimado
          Blynk.virtualWrite(V35,740); //costo estimado
        } 
        break;
        case 4:{
          Blynk.virtualWrite(V33,0.03);//KWh estimado          
          Blynk.virtualWrite(V34,22);//KWh mes estimado
          Blynk.virtualWrite(V35,330); //costo estimado
        }  
        break; 
        default:
        break;
     }
  } 
  BanderaSeleccionMenuArtefacto=2;
  consejos();
}

void consejos(){//PIN V38
  if (BanderaSeleccionMenuArtefacto==0){  
    Blynk.setProperty(V38, "offImageUrl", "https://i.postimg.cc/BbMt903V/Consejos.png");
  }
  else if (BanderaSeleccionMenuArtefacto==1){//ILUMINACION
    Blynk.setProperty(V38, "offImageUrl", "https://i.postimg.cc/XqVXzvR5/1BIS-PS.png");
    Blynk.setProperty(V38, "url", "https://wordpress.com/2022/12/04/iluminacion/");
  }
  else if (BanderaSeleccionMenuArtefacto==2){//REFRIGERACION
    Blynk.setProperty(V38, "offImageUrl", "https://i.postimg.cc/g2rLpnnq/2BIS-PS.png");
    Blynk.setProperty(V38, "url", "https://wordpress.com/2022/12/04/refrigeracion/");
  }
  else if (BanderaSeleccionMenuArtefacto==3){ //LINEA BLANCA
    Blynk.setProperty(V38, "offImageUrl", "https://i.postimg.cc/RZ86Z4tr/3BIS-PS.png");
    Blynk.setProperty(V38, "url", "https://wordpress.com/2022/12/04/linea-blanca/");//puede ir cada uno a una foto.
  }
  else if (BanderaSeleccionMenuArtefacto==4){ //COCINA
    Blynk.setProperty(V38, "offImageUrl", "https://i.postimg.cc/qRczwK50/4BIS-PS.png");
    Blynk.setProperty(V38, "url", "https://wordpress.com/2022/12/04/cocina/");
  }
  else if (BanderaSeleccionMenuArtefacto==5){ //CLIMATIZACION
    Blynk.setProperty(V38, "offImageUrl", "https://i.postimg.cc/nVYDYyy7/5BIS-PS.png");
    Blynk.setProperty(V38, "url", "https://wordpress.com/2022/12/04/climatizacion/");
  }
  else if (BanderaSeleccionMenuArtefacto==6){//ELECTRONICA
    Blynk.setProperty(V38, "offImageUrl", "https://i.postimg.cc/sDjZnnzL/6BIS-PS.png");
    Blynk.setProperty(V38, "url", "https://wordpress.com/2022/12/04/electronica-audio-y-video/");
  }
  else if (BanderaSeleccionMenuArtefacto==7){//CUIDAD PERSONAL
    Blynk.setProperty(V38, "offImageUrl", "https://i.postimg.cc/7YKJjgYZ/7BIS-PS.png");
    Blynk.setProperty(V38, "url", "https://wordpress.com/2022/12/04/cuidado-personal/");
  }
  else if (BanderaSeleccionMenuArtefacto==8){///AGUA
    Blynk.setProperty(V38, "offImageUrl", "https://i.postimg.cc/NMvKRDbp/8BIS-PS.png");
    Blynk.setProperty(V38, "url", "https://wordpress.com/2022/12/04/agua/");
  }
}


BLYNK_CONNECTED(){
  rtc.begin();
  BanderaSeleccionMenuArtefacto=0;
  consejos();
  flagSubsidio=3;
}

void clockDisplay() {
  String currentTime = String(hour()) + ":" + minute();
  String currentDate = String(day()) + " " + month() + " " + year();
  Blynk.virtualWrite(V4, currentTime);
  Blynk.virtualWrite(V5, currentDate);
}

void setup() {
  Serial.begin(9600);
  EEPROM.begin(EEPROM_SIZE);
  BlynkEdgent.begin();
  SPI.begin();
  radio.begin();
  network.begin(90, this_node);
  radio.setDataRate(RF24_2MBPS);
  setSyncInterval(10 * 60);  // Sync interval in seconds (10 minutes)
  timer.setInterval(1000L, clockDisplay);
  timer.setInterval(1000L, sendSensor);
}

void loop() {
  BlynkEdgent.run();
  timer.run();
  network.update();
}

@PabloBck Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Pete.

1 Like

There are a few issues with your code, but you should start by installing the exception decoder and pasting your error into it and studying the result.

Pete.