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
- 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
- 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
- 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);
}
}