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

Button with code

Exactly! he now seems to have lost the will to live!

Pete.

2 Likes

:joy::joy::joy::joy:

1 Like

Sorry, but my work takes a long time…

WidgetTerminal terminal (V30);

BLYNK_WRITE(V30)
{
  if (String("YOUR PASSWORD HERE") == param.asStr()) {
terminal.println("Password accepted") ;
Blynk.notify("Warning,......");
terminal.write(x = param.asInt());
  } else {
terminal.print("Password denied");
Blynk.notify("Warning, .....");
Blynk.email("YOUR EMAIL HERE", "Failed access", "........");
terminal.write(param.getBuffer(), param.getLength());
terminal.println();
  }
  terminal.flush();
}
void setup()

How would you like us to help you with this?

Pete.

//Librerie e definizione hardware
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <BlynkSimpleEthernet.h>
#include <SoftwareSerial.h>
#define SIM800_TX_PIN 8                                //SIM800 TX al pin D8 di to Arduino
#define SIM800_RX_PIN 7                                //SIM800 TX al pin D7 di to Arduino
SoftwareSerial mySerial(SIM800_TX_PIN, SIM800_RX_PIN); //Creazione software serial per SIM800C
#define reed 2
#define tamper 3
#define led_1 9
#define led_2 6
#define W5100_CS  10
#define SDCARD_CS 4
int x;
SimpleTimer timer;


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


//sync time ntp
EthernetUDP Udp;
IPAddress server_ip ( 139, 59, 206, 133); //cloud blynk
// Mac address should be different for each device in your LAN
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress arduino_ip ( 192, 168, 188, 98);
IPAddress dns_ip     (  8,  8,  8,  8);
IPAddress gateway_ip ( 192, 168, 188, 001);
IPAddress subnet_mask( 255, 255, 255, 000);
EthernetServer server = EthernetServer(80);


//variabili lettura sms in entrata
char stringa[100];
char comando[31] = {0};


// variabili antifurto
bool stato_imp = false;
volatile int stato_reed  = LOW;
volatile int stato_tamper = LOW;
String number = "xxxxxxxxxxx";


WidgetTerminal terminal (V30);

BLYNK_WRITE(V30)
{
  if (String("YOUR PASSWORD HERE") == param.asStr()) {
terminal.println("Password accepted") ;
Blynk.notify("Warning,......");
terminal.write(x = param.asInt());
  } else {
terminal.print("Password denied");
Blynk.notify("Warning, .....");
Blynk.email("YOUR EMAIL HERE", "Failed access", "........");
terminal.write(param.getBuffer(), param.getLength());
terminal.println();
  }
  terminal.flush();
}
void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);
  delay(10000);                             // attendo che il GSM abbia agganciato la linea
  mySerial.print("AT+CMGF=1\r\n");          // imposta il formato del messaggio SMS come testo
  delay(1000);
  mySerial.print("AT+CNMI=1,2,0,0,0\r\n");  // specifica come devono essere gestiti i messaggi SMS appena arrivati
  delay(1000);
  pinMode(reed, INPUT);
  attachInterrupt(digitalPinToInterrupt(reed), line_reed, FALLING );    // FALLING = da alto a basso.
  pinMode(tamper, INPUT);
  attachInterrupt(digitalPinToInterrupt(tamper), line_tamper, FALLING );  // FALLING = da alto a basso.
  pinMode(led_1, OUTPUT);
  digitalWrite(led_1, LOW);
  pinMode(led_2, OUTPUT);
  digitalWrite(led_2, LOW);
    Blynk.begin(auth, "blynk-cloud.com", 8080, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
}


void line_reed()
{
  stato_reed = HIGH;
}


void line_tamper()
{
  stato_tamper = HIGH;
}


void antifurto() {

  if (x == 1) {
  if (stato_imp = true) { // flag impianto inserito
    number1inserito();
    number2inserito();
    digitalWrite(led_1, HIGH); // spegne il LED (LOW l'uscita viene disalimentata)
    
    if (stato_reed == HIGH) { // contatto porta aperto
      number1allarme();
      number2allarme();
      digitalWrite(led_2, HIGH);  // accende led segnalazione allarme
    
    }
    if (stato_tamper == HIGH) { // linea tamper aperta
      number1allarme();
      number2allarme();
      digitalWrite(led_2, HIGH); // accende led segnalazione allarme
    }
  }
  else if (stato_imp = false) { // flag impianto disinserito
    number1disinserito();
    number2disinserito();
    digitalWrite(led_1, LOW);  // spengne led a impianto disinserito
    digitalWrite(led_2, LOW); // spegne led segnalazione allarme
  }
}
}

void number1allarme()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Attenzione, centrale in allarme");
  Serial.write(0x1A);
  delay(1000);
}


void number2allarme()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Attenzione centrale in allarme");
  Serial.write(0x1A);
  delay(1000);
}


void number1inserito()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Sistema allarme inserito");
  Serial.write(0x1A);
  delay(1000);
}


void number2inserito()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Sistema allarme inserito");
  Serial.write(0x1A);
  delay(1000);
}


void number1disinserito()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Sistema allarme OFF");
  Serial.write(0x1A);
  delay(1000);
}


void number2disinserito()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Sistema allarme OFF");
  Serial.write(0x1A);
  delay(1000);
}


void lettura_sms() {
  if (mySerial.available()) {
    mySerial.readString().toUpperCase();                         // rendo maiuscola tutta la stringa per evitare errori di sintassi
    mySerial.readString().toCharArray(stringa, 100);              // converto la stringa message nell'array stringa
      strncpy(comando, stringa, 30);                                // copio in comando la prima parte del messaggio ricevuto ossia: +CMT "+39numerotelefono"
    Serial.println(comando);
      if (strncmp(comando, "+39xxxxxxxxx", 13) == 0) {             // poi controllo se in comando sia presente il numero del mittente autorizzato
      if (strncmp(comando, "ON", 2) == 0) {                       // e inserisco impianto
        stato_imp = true;
      }
      else if (strncmp(comando, "OFF", 3) == 0) {                  // o disinserisco impianto
        stato_imp = false;
      }
    }
    mySerial.print("AT+CMGDA=\"");
    mySerial.println("DEL ALL\"");                                // cancello tutti i messaggi
  }
}


void loop()
{
  lettura_sms();
  antifurto();
  Blynk.run();
  timer.run();
}

this is my code

You keep posting pieces of code here, without any explanation attached. We have no idea if these even compile successfully, never mind how they actually perform in practice with your app and hardware.

Before your recent break, we were discussing flags, and you seemed to believe that you were using an integer variable called x as a flag, but there was no evidence of this in your code.

My recommendation would be to add some meaningful serial prints statements to your code, then try to track the flow of your program when your widgets are activated.
If you want assistance in debugging the issues that you have then share this full code, along with some annotated serial print data that identifies which widgets were used, and what results you observed with your relay hardware.

You’ll also need to provide clear and meaningful answered to questions, rather than replying with a different piece of code and no contextual information.

Pete.

sorry Pete, but my problem and this
if insert a widget terminal not function , the complete code is

//Librerie e definizione hardware
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <BlynkSimpleEthernet.h>
#include <SoftwareSerial.h>
#define SIM800_TX_PIN 8                                //SIM800 TX al pin D8 di to Arduino
#define SIM800_RX_PIN 7                                //SIM800 TX al pin D7 di to Arduino
SoftwareSerial mySerial(SIM800_TX_PIN, SIM800_RX_PIN); //Creazione software serial per SIM800C
#define reed 2
#define tamper 3
#define led_1 9
#define led_2 6
#define W5100_CS  10
#define SDCARD_CS 4
int x;
SimpleTimer timer;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "53ba61850d8d423d889becf5b86248ab";
//sync time ntp
EthernetUDP Udp;
IPAddress server_ip ( 139, 59, 206, 133); //cloud blynk
// Mac address should be different for each device in your LAN
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress arduino_ip ( 192, 168, 188, 98);
IPAddress dns_ip     (  8,  8,  8,  8);
IPAddress gateway_ip ( 192, 168, 188, 001);
IPAddress subnet_mask( 255, 255, 255, 000);
EthernetServer server = EthernetServer(80);
//variabili lettura sms in entrata
char stringa[100];
char comando[31] = {0};
// variabili antifurto
bool stato_imp = false;
volatile int stato_reed  = LOW;
volatile int stato_tamper = LOW;
String number = "xxxxxxxxxxx";
WidgetTerminal terminal (V30);
BLYNK_WRITE(V30)
{
  if (String("YOUR PASSWORD HERE") == param.asStr()) {
terminal.println("Password accepted") ;
Blynk.notify("Warning,......");
terminal.write(x = param.asInt());
  } else {
terminal.print("Password denied");
Blynk.notify("Warning, .....");
Blynk.email("YOUR EMAIL HERE", "Failed access", "........");
terminal.write(param.getBuffer(), param.getLength());
terminal.println();
  }
  terminal.flush();
}
void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);
  delay(10000);                             // attendo che il GSM abbia agganciato la linea
  mySerial.print("AT+CMGF=1\r\n");          // imposta il formato del messaggio SMS come testo
  delay(1000);
  mySerial.print("AT+CNMI=1,2,0,0,0\r\n");  // specifica come devono essere gestiti i messaggi SMS appena arrivati
  delay(1000);
  pinMode(reed, INPUT);
  attachInterrupt(digitalPinToInterrupt(reed), line_reed, FALLING );    // FALLING = da alto a basso.
  pinMode(tamper, INPUT);
  attachInterrupt(digitalPinToInterrupt(tamper), line_tamper, FALLING );  // FALLING = da alto a basso.
  pinMode(led_1, OUTPUT);
  digitalWrite(led_1, LOW);
  pinMode(led_2, OUTPUT);
  digitalWrite(led_2, LOW);
    Blynk.begin(auth, "blynk-cloud.com", 8080, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
}
void line_reed()
{
  stato_reed = HIGH;
}
void line_tamper()
{
  stato_tamper = HIGH;
}
void antifurto() {
  if (x == 1) {
  if (stato_imp = true) { // flag impianto inserito
    number1inserito();
    number2inserito();
    digitalWrite(led_1, HIGH); // spegne il LED (LOW l'uscita viene disalimentata)
        if (stato_reed == HIGH) { // contatto porta aperto
      number1allarme();
      number2allarme();
      digitalWrite(led_2, HIGH);  // accende led segnalazione allarme
        }
    if (stato_tamper == HIGH) { // linea tamper aperta
      number1allarme();
      number2allarme();
      digitalWrite(led_2, HIGH); // accende led segnalazione allarme
    }
  }
  else if (stato_imp = false) { // flag impianto disinserito
    number1disinserito();
    number2disinserito();
    digitalWrite(led_1, LOW);  // spengne led a impianto disinserito
    digitalWrite(led_2, LOW); // spegne led segnalazione allarme
  }
}
}
void number1allarme()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Attenzione, centrale in allarme");
  Serial.write(0x1A);
  delay(1000);
}
void number2allarme()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Attenzione centrale in allarme");
  Serial.write(0x1A);
  delay(1000);
}
void number1inserito()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Sistema allarme inserito");
  Serial.write(0x1A);
  delay(1000);
}
void number2inserito()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Sistema allarme inserito");
  Serial.write(0x1A);
  delay(1000);
}
void number1disinserito()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Sistema allarme OFF");
  Serial.write(0x1A);
  delay(1000);
}
void number2disinserito()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Sistema allarme OFF");
  Serial.write(0x1A);
  delay(1000);
}
void lettura_sms() {
  if (mySerial.available()) {
    mySerial.readString().toUpperCase();                         // rendo maiuscola tutta la stringa per evitare errori di sintassi
    mySerial.readString().toCharArray(stringa, 100);              // converto la stringa message nell'array stringa
      strncpy(comando, stringa, 30);                                // copio in comando la prima parte del messaggio ricevuto ossia: +CMT "+39numerotelefono"
    Serial.println(comando);
      if (strncmp(comando, "+39xxxxxxxxx", 13) == 0) {             // poi controllo se in comando sia presente il numero del mittente autorizzato
      if (strncmp(comando, "ON", 2) == 0) {                       // e inserisco impianto
        stato_imp = true;
      }
      else if (strncmp(comando, "OFF", 3) == 0) {                  // o disinserisco impianto
        stato_imp = false;
      }
    }
    mySerial.print("AT+CMGDA=\"");
    mySerial.println("DEL ALL\"");                                // cancello tutti i messaggi
  }
}
void loop()
{
  lettura_sms();
  antifurto();
  Blynk.run();
  timer.run();
}

ok??

if i use the button with this code is ok , all function , the complete code is

//Librerie e definizione hardware
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <BlynkSimpleEthernet.h>
#include <SoftwareSerial.h>
#define SIM800_TX_PIN 8                                //SIM800 TX al pin D8 di to Arduino
#define SIM800_RX_PIN 7                                //SIM800 TX al pin D7 di to Arduino
SoftwareSerial mySerial(SIM800_TX_PIN, SIM800_RX_PIN); //Creazione software serial per SIM800C
#define reed 2
#define tamper 3
#define led_1 9
#define led_2 6
#define W5100_CS  10
#define SDCARD_CS 4
int x;
SimpleTimer timer;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "53ba61850d8d423d889becf5b86248ab";
//sync time ntp
EthernetUDP Udp;
IPAddress server_ip ( 139, 59, 206, 133); //cloud blynk
// Mac address should be different for each device in your LAN
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress arduino_ip ( 192, 168, 188, 98);
IPAddress dns_ip     (  8,  8,  8,  8);
IPAddress gateway_ip ( 192, 168, 188, 001);
IPAddress subnet_mask( 255, 255, 255, 000);
EthernetServer server = EthernetServer(80);
//variabili lettura sms in entrata
char stringa[100];
char comando[31] = {0};
// variabili antifurto
bool stato_imp = false;
volatile int stato_reed  = LOW;
volatile int stato_tamper = LOW;
String number = "xxxxxxxxxxx";
BLYNK_CONNECTED() {
      Blynk.syncVirtual(V30);
  }
BLYNK_WRITE(V30){
 x = param.asInt();
 }
void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);
  delay(10000);                             // attendo che il GSM abbia agganciato la linea
  mySerial.print("AT+CMGF=1\r\n");          // imposta il formato del messaggio SMS come testo
  delay(1000);
  mySerial.print("AT+CNMI=1,2,0,0,0\r\n");  // specifica come devono essere gestiti i messaggi SMS appena arrivati
  delay(1000);
  pinMode(reed, INPUT);
  attachInterrupt(digitalPinToInterrupt(reed), line_reed, FALLING );    // FALLING = da alto a basso.
  pinMode(tamper, INPUT);
  attachInterrupt(digitalPinToInterrupt(tamper), line_tamper, FALLING );  // FALLING = da alto a basso.
  pinMode(led_1, OUTPUT);
  digitalWrite(led_1, LOW);
  pinMode(led_2, OUTPUT);
  digitalWrite(led_2, LOW);
    Blynk.begin(auth, "blynk-cloud.com", 8080, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
}
void line_reed()
{
  stato_reed = HIGH;
}
void line_tamper()
{
  stato_tamper = HIGH;
}
void antifurto() {
  if (x == 1) {
  if (stato_imp = true) { // flag impianto inserito
    number1inserito();
    number2inserito();
    digitalWrite(led_1, HIGH); // spegne il LED (LOW l'uscita viene disalimentata)
     if (stato_reed == HIGH) { // contatto porta aperto
      number1allarme();
      number2allarme();
      digitalWrite(led_2, HIGH);  // accende led segnalazione allarme
      }
    if (stato_tamper == HIGH) { // linea tamper aperta
      number1allarme();
      number2allarme();
      digitalWrite(led_2, HIGH); // accende led segnalazione allarme
    }
  }
  else if (stato_imp = false) { // flag impianto disinserito
    number1disinserito();
    number2disinserito();
    digitalWrite(led_1, LOW);  // spengne led a impianto disinserito
    digitalWrite(led_2, LOW); // spegne led segnalazione allarme
  }
}
}
void number1allarme()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Attenzione, centrale in allarme");
  Serial.write(0x1A);
  delay(1000);
}
void number2allarme()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Attenzione centrale in allarme");
  Serial.write(0x1A);
  delay(1000);
}
void number1inserito()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Sistema allarme inserito");
  Serial.write(0x1A);
  delay(1000);
}
void number2inserito()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Sistema allarme inserito");
  Serial.write(0x1A);
  delay(1000);
}
void number1disinserito()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Sistema allarme OFF");
  Serial.write(0x1A);
  delay(1000);
}
void number2disinserito()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Sistema allarme OFF");
  Serial.write(0x1A);
  delay(1000);
}
void lettura_sms() {
  if (mySerial.available()) {
    mySerial.readString().toUpperCase();                         // rendo maiuscola tutta la stringa per evitare errori di sintassi
    mySerial.readString().toCharArray(stringa, 100);              // converto la stringa message nell'array stringa
      strncpy(comando, stringa, 30);                                // copio in comando la prima parte del messaggio ricevuto ossia: +CMT "+39numerotelefono"
    Serial.println(comando);
      if (strncmp(comando, "+39xxxxxxxxx", 13) == 0) {             // poi controllo se in comando sia presente il numero del mittente autorizzato
      if (strncmp(comando, "ON", 2) == 0) {                       // e inserisco impianto
        stato_imp = true;
      }
      else if (strncmp(comando, "OFF", 3) == 0) {                  // o disinserisco impianto
        stato_imp = false;
      }
    }
    mySerial.print("AT+CMGDA=\"");
    mySerial.println("DEL ALL\"");                                // cancello tutti i messaggi
  }
}
void loop()
{
  lettura_sms();
  antifurto();
  Blynk.run();
  timer.run();
}

my problem is a blynk write , in the code with the button (second posted), my variable x is correct, while in the first code I don’t know how to handle it.

my variable x is the one that turns my antifurto on and off

Forget the idea of posting two sets of code, it doesn’t help.
Focus on your current code (the first one I think) and answer these questions:

  1. Is your terminal widget connected to V30?
  2. Show me the one line of code where x is set to 1

Pete.

my widget is on v30, but i don’t understand how to set x = 1 i set it to void antifurto no on v30

void antifurto() {

  if (x == 1) {

That’s the point. This is testing if it ==1 not setting it to 1.

This is what we are trying to help your understand…

BLYNK_WRITE(V30)
{
  if (String("YOUR PASSWORD HERE") == param.asStr()) { // <<< (1)
terminal.println("Password accepted") ; // <<< (2)
Blynk.notify("Warning,......");
terminal.write(x = param.asInt()); // <<< (3)
  } else {
terminal.print("Password denied");
Blynk.notify("Warning, .....");
Blynk.email("YOUR EMAIL HERE", "Failed access", "........");
terminal.write(param.getBuffer(), param.getLength());
terminal.println();
  }
  terminal.flush();
}

When you press OK/Send or whatever on the terminal widget, your function BLYNK_WRITE(V30) is executed.

When you enter the text “1111”, like at point (1). you get into the if statement at point (2)

You then type some more text and try to get the info at point (3) but if you do this, your ar not setting x = 1 or even x = param.asInt() - you are just typing back to the terminal what you input.

But then even if you did do this then param.asStr() and param.asInt() cannot equal “1111” to tget to if statement at point (1) and at the same time equal ‘1’ for x

1 Like