debouching logic not working

Hello, I am new in Arduino programming .Please see below my code. its very simple but its not working. Actually I want to develop one zone fire system with one rely & LED output. Please see below my code. Its not working any thing,

Program :-

/* One Zone Fire Alarm Panel * one momentary switch is connected to pin 2, RED led connected to pin 13 & one relay connected to pin 3; * Working:- 1) When switch_Fire will press first LED will glow continuously as well as relay will also turn ON till manual RESET button not press by user 2) If fire is there i.e. LED anf relay are activated and if some one press bypass switch than only Relay will turn OFF but LED is going ON till reset 3) If first press bypass switch (monetary) and fire will occurs (press switch_Fire) then only FIRE LED will glow but relay will not be activate 4) NOTE :- 500mS debouching delay will use for both fire & bypass switches. Author:- Surajk Date:- 13 Aug 2019 Project Name:- Fire Panel */

const int switch_Fire = 2; // Pulse / momentary type NO switch connected for fire alarm simulation const int bypass = 3; // Pulse / momentary type NO switch connected for bypass alarm const int Fire_led = 13; // Alarm RED LED is connected for visual indication const int Fire_Rely = 4; // One relay latch-able connected if fire occurs or switch_Fire will press

int switch_Fire_state = 0; // Store switch_Fire status int bypass_state = 0; // Store bypass status unsigned long debouching_delay = 500; // set debouching delay at 500mS for avoiding false alarm activation

void setup() { pinMode(switch_Fire, INPUT); // Set switch_Fire as a input pinMode(bypass, INPUT); // Set bypass as a input pinMode(Fire_led,OUTPUT); // Set Fire_led as a output pinMode(Fire_Rely,OUTPUT); // Set Fire_Rely as a output

}

void loop() {

switch_Fire_state = digitalRead(switch_Fire); // Read switch_Fire switch status and store in "switch_Fire_state".

if (switch_Fire_state == HIGH) {

int value = millis();

if ((millis() - value) > debouching_delay) {

fire(); // call fire function } }

bypass_state = digitalRead(bypass); // Read bypass switch status and store in "bypass_state".

if (bypass_state == HIGH) {

int value = millis();

if ((millis() - value) > debouncing_delay) {

bypass_function(); // call bypass function } }

}

void fire() // fire function use for taking action if "switch_fire" switch will press {

if ((switch_Fire_state == HIGH) && (bypass == LOW)) {

int value = millis();

if ((millis() - value) > debouching_delay) {

digitalWrite (Fire_led, HIGH); digitalWrite (Fire_Rely, HIGH); } } else { digitalWrite (Fire_led, LOW); digitalWrite (Fire_Rely, LOW); }

}

void bypass_function () // bypass function use for taking action if bypass switch will press

{

if ((switch_Fire_state == HIGH) && (bypass == HIGH)) {

int value = millis();

if ((millis() - value) > debouching_delay) {

digitalWrite (Fire_led, HIGH); digitalWrite (Fire_Rely, HIGH); } } else { digitalWrite (Fire_led, LOW); digitalWrite (Fire_Rely, LOW); }

}

Read how to use the forum

Read the tutorial at the top of the forum on how to use millis() (and unsigned long)

Try to explain in plain English your denouncing logic and see if this is what you coded

Do you have external pull-up or pull-down?

Please correct your post above and add code tags around your code: [code][color=blue]// your code is here[/color][/code].

It should look like this:// your code is here (Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)

These two lines

 int value = millis();
    if ((millis() - value) > debouching_delay) {

set the content of value and then in the next line (less than a microsecond later) checks to see if 500 millisecs has passed. It never will have.

…R

PS … To make it easy for people to help you please modify your post and use the code button </>

so your code 
looks like this

and is easy to copy to a text editor. See How to use the Forum

Also please use the AutoFormat tool to indent your code consistently for easier reading.

  pinMode(switch_Fire, INPUT); // Set switch_Fire as a input
  pinMode(bypass, INPUT); // Set bypass as a input

You are not using INPUT_PULLUP so do you have the necessary pull-up or pull-down resistor on your input pins? If your pin is connected to a switch and the switch is open, the pin will float to a random state. If the switch is between the pin and Ground you need a resistor (10k Ohms is typical) from the pin to +5V to cause it to read HIGH when the switch is open. If the switch is between the pin and +5V you need a resistor (10k Ohms is typical) from the pin to Ground to cause it to read LOW when the switch is open.