Blynk iot overide sensor or disable sensor

i am working on alarm project and i am using a magnetic sensor for door when the door is open the buzzer will HIGH, So now i want to override (bypass) the sensor using Botton, example once Button is on the sensor pin is need to disable.

i hope you hear me soon

Best Regard
Maaz

#define BLYNK_DEVICE_NAME           "Device"

#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

#define APP_DEBUG

// Uncomment your board, or configure a custom board in Settings.h
#define USE_WROVER_BOARD
//#define USE_TTGO_T7

#include "BlynkEdgent.h"
bool alarm_mode = false ;
int ZONE1 = 32;
int buzzer = 22;
int botton = 2;
BlynkTimer timer;
void myTimerEvent(){
  if(digitalRead(ZONE1) ==0){
    Blynk.virtualWrite(V1,"CLOSE");
    
  }
  if(digitalRead(ZONE1) ==1){
    Blynk.virtualWrite(V1,"OPEN");
    if(alarm_mode == true){
      digitalWrite(buzzer, HIGH);
     }
  }
}
BLYNK_WRITE(V2)
{
  if ( param.asInt () == 1)    // <------ ZONE1 BYPASS
{
  digitalWrite(32,HIGH);
}
  else
  {
    digitalWrite(32,LOW);
  }
}
void setup()
{
  pinMode(ZONE1,INPUT_PULLUP);
  pinMode (botton,OUTPUT);
  pinMode (buzzer,OUTPUT);
  Serial.begin(115200);
  delay(100);

  BlynkEdgent.begin();
}

void loop() {
  BlynkEdgent.run();
  timer.run();
  Blynk.run();
}

Hi Maaz

Can you explain a little more what you want to achieve? It's not very clear.

Is the button you mentioned real or virtual?

If it is a real button, why do you set it as OUTPUT?

pinMode (botton,OUTPUT);

thanks for reply sir
sir i set as a OUTPUT because uing this Botton i am trying to bypass the sensor
i want to disable the sensor using botton ,once botton is (HIGH) sensor will bypass means disable ,botton will (LOW) sensor work normal

Best Regards
Maaz

It must be difficult to explain in a foreign language, I understand.

Perhaps if you could draw a diagram? It could show how the sensor is connected and what the output you call "botton" is connected.

Thanks for reply sir
i attached here the sensor picture for your refrence this is just a example sir
pinMode(ZONE1,INPUT_PULLUP);


Best Regards
Maaz

It didn't. Oh, well.

Hi @sahikmaaz
I have never used this library:

But what is this?
A special library function?

@ruilviana
thanks for reply this is a blynk iot software For Botton commond

Best Regards
Maaz

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.