BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Help with numeric input

Hi blynkers!
I’m trying to use the numeric input, but I not sure what I’m doing wrong

#include <IRremoteESP8266.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>



// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";

int arcond = 0;

IRsend irsend(14);


void setup()
{
  // Debug console
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  digitalWrite(4, 0);
  digitalWrite(5, 0);
  Serial.begin(115200);
  irsend.begin();
  Blynk.begin(auth, ssid, pass);
  ArduinoOTA.setHostname("Sanca");
  Serial.println("Booting");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, pass);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Connection Failed! Rebooting...");
    delay(5000);
    ESP.restart();
 
}

 ArduinoOTA.onStart([]() {
    String type;
    if (ArduinoOTA.getCommand() == U_FLASH)
      type = "sketch";
    else // U_SPIFFS
      type = "filesystem";

    // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
    Serial.println("Start updating " + type);
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
    else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
    else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
    else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
    else if (error == OTA_END_ERROR) Serial.println("End Failed");
  });
  ArduinoOTA.begin();
  Serial.println("Ready");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}



// 18°
unsigned int LD[119] = {8440, 4196, 616, 1608, 640, 484, 612, 512, 592, 508, 640, 1608, 616, 480, 620, 508, 616, 508, 588, 1636, 612, 1608, 644, 484, 588, 536, 616, 508, 588, 536, 540, 584, 588, 512, 592, 532, 588, 540, 584, 512, 588, 540, 560, 560, 536, 1688, 560, 568, 560, 1660, 540, 612, 536, 564, 532, 592, 536, 1688, 536, 62268, 8448, 4160, 624, 1628, 596, 528, 600, 500, 620, 504, 596, 1624, 624, 504, 596, 528, 596, 504, 624, 496, 600, 528, 600, 496, 624, 504, 600, 524, 596, 504, 624, 500, 596, 528, 600, 500, 624, 500, 600, 1620, 628, 1620, 600, 504, 624, 1624, 600, 496, 624, 504, 600, 524, 596, 1628, 596, 1628, 620, 1628, 596}; //COLE A LINHA RAW CORRESPONDENTE DENTRO DAS CHAVES
// 20
unsigned int MT[125] = {3904, 360, 1444, 880, 300, 724, 220, 4824, 508, 1740, 484, 668, 460, 668, 480, 648, 396, 1772, 532, 620, 476, 620, 480, 672, 428, 1740, 484, 1740, 560, 720, 380, 588, 508, 596, 500, 620, 508, 724, 400, 648, 480, 696, 372, 644, 508, 724, 424, 752, 352, 668, 376, 1824, 424, 780, 400, 1688, 484, 644, 504, 620, 508, 696, 372, 1772, 480, 62976, 8416, 4188, 624, 1628, 596, 504, 624, 500, 596, 528, 596, 1628, 596, 532, 592, 504, 624, 496, 600, 528, 600, 496, 624, 504, 592, 532, 596, 504, 620, 504, 596, 528, 596, 500, 624, 504, 596, 1624, 624, 504, 596, 1628, 624, 500, 596, 1624, 624, 504, 592, 536, 592, 1628, 596, 528, 596, 504, 620, 1628, 596}; //COLE A LINHA RAW CORRESPONDENTE DENTRO DAS CHAVES
// 22°
unsigned int PP[119] = {8448, 4160, 624, 1628, 596, 500, 624, 504, 596, 524, 600, 1624, 600, 524, 596, 504, 624, 500, 596, 1628, 624, 1624, 600, 504, 620, 500, 600, 528, 592, 504, 624, 500, 596, 528, 600, 500, 624, 500, 600, 524, 600, 500, 624, 500, 600, 1624, 624, 500, 600, 1624, 624, 504, 596, 524, 600, 496, 628, 1624, 596, 41976, 8424, 4188, 624, 1624, 600, 496, 624, 504, 600, 524, 596, 1628, 596, 528, 600, 500, 624, 500, 600, 524, 596, 504, 620, 504, 596, 532, 592, 504, 624, 500, 596, 528, 600, 500, 624, 500, 600, 1620, 624, 1628, 596, 1628, 596, 528, 600, 1620, 600, 528, 596, 504, 620, 1624, 600, 504, 624, 1624, 600, 1624, 600}; //COLE A LINHA RAW CORRESPONDENTE DENTRO DAS CHAVES
// 24°
unsigned int VV[60] = {8400, 4200, 600, 1550, 600, 500, 550, 500, 600, 500, 550, 1550, 600, 500, 550, 500, 600, 500, 550, 500, 600, 500, 550, 500, 600, 500, 550, 500, 600, 500, 550, 500, 600, 500, 550, 1550, 600, 500, 600, 500, 550, 1550, 600, 500, 600, 1550, 600, 500, 600, 1550, 600, 1550, 600, 1550, 600, 1550, 600, 500, 550};
// 26°
unsigned int MM[60] = {8400, 4200, 600, 1550, 600, 500, 600, 500, 600, 500, 600, 1550, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 500, 600, 1550, 600, 500, 600, 1550, 600, 1550, 600, 500, 600, 1550, 600, 500, 600, 1550, 600, 500, 600, 500, 600, 500, 600, 500, 600}; 
// Of
unsigned int VT[59] = {8448, 4192, 592, 1624, 628, 500, 600, 528, 592, 504, 632, 1616, 600, 504, 620, 500, 600, 528, 592, 1628, 596, 1628, 624, 500, 600, 528, 596, 500, 624, 500, 596, 532, 596, 500, 624, 504, 596, 524, 600, 500, 624, 500, 600, 528, 596, 1628, 596, 524, 600, 1624, 600, 528, 596, 500, 624, 504, 596, 1624, 628}; //COLE A LINHA RAW CORRESPONDENTE DENTRO DAS CHAVES


BLYNK_WRITE(V4) {
  switch (param.asInt())
  {
    case 1: // Item 1
        irsend.sendRaw(LD,119,32);  // PARÂMETROS NECESSÁRIOS PARA ENVIO DO SINAL IR
        Blynk.setProperty(V4, "color", "#04C0F8");
        break;
    case 2: // Item 2
        irsend.sendRaw(MT,125,32);  // PARÂMETROS NECESSÁRIOS PARA ENVIO DO SINAL IR
        Blynk.setProperty(V4, "color", "#04C0F8");
        break;
    case 3: // Item 3
        irsend.sendRaw(PP,119,32);  // PARÂMETROS NECESSÁRIOS PARA ENVIO DO SINAL IR
        Blynk.setProperty(V4, "color", "#04C0F8");
        break;
    case 4: // Item 4
        irsend.sendRaw(VV,60,28);  // PARÂMETROS NECESSÁRIOS PARA ENVIO DO SINAL IR
        Blynk.setProperty(V4, "color", "#04C0F8");
        break;
    case 5: // Item 5
        irsend.sendRaw(MM,60,28);  // PARÂMETROS NECESSÁRIOS PARA ENVIO DO SINAL IR
        Blynk.setProperty(V4, "color", "#04C0F8");
        break;
    case 6: // Item 5
        irsend.sendRaw(VT,59,32);  // PARÂMETROS NECESSÁRIOS PARA ENVIO DO SINAL IR
        Blynk.setProperty(V4, "color", "#D3435C");
        break;
    default:
      Serial.println("Unknown item selected");
  }
}

BLYNK_WRITE(V3){
          if(arcond == 0 && V2 == 18){
            irsend.sendRaw(LD,119,32);
            Blynk.virtualWrite(V4, 18);
            arcond = param.asInt();

}



void loop() {
  Blynk.run();
  ArduinoOTA.handle();
}

The numeric input is on V2 and I’m trying to use it with a button on V3

More info on what you want it to do, what it is doing and what you have tried, will go a long way… not too many are going to read through your code to figure all that out.

The idea is when I press V3 it needs to read the number um the numeric input to send the right comand to the air conditioning

e.g. If the numeric input shows the number 18 it has to send the IR code of 18 degrees

Take a look at my water tank project… Water Tank Level Indicator with Low Level Warning Notifications . I’ve used numeric input which is activated on and off with a button widget. With a slight mod to the code you maybe able to achieve what you need.

1 Like

So… the problem is that in order to read values from Virtual Pins, you cannot do things like

... V2 == 18

You need to use the function BLYNK_WRITE(V_PIN), that is called every time the value held by V_PIN is changed by your app.

What I would do is set a global variable and have this function modify it every time the value in V2 is changed.

Something like this:

int temp;

BLYNK_WRITE(V2) {   

  temp = param.asInt(); // Gets the value stored in V2 as an integer

}