Hi
I am making a fire system to turn pumps on.
I am having issues with sudden detection of pulse at pin8 which causes false alarm and triggers.
I read some articles and made pin8 to read LOW, but still I faced false triggers.
I can use milis to solve this issue to read pulse for some seconds, but this is not the correct solution.
I need to run project when real pulse hit pin8.
Please go through my code and advise me where I am wrong.
Thanks, your response would be appriciated
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity
int ch1 = 6; //Grid Sense INPUT
int ch2 = 7; // Generator Sense INPUT
int ch3 = 8; // FLOW switch sense INPUT
int ch4 = 9; // Reset OUTPUT
int ch5 = 10; // Choke OUTPUT
int ch6 = 11; // Self OUTPUT
int ch7 = 22; //Grid Contactor OUTPUT
int ch8 = 33; // Generator Contactor OUTPUT
int i = 1;
int flag=0;
void setup()
{
Serial.begin(9600);
pinMode(ch1, INPUT_PULLUP); //Grid Sense INPUT
pinMode(ch2, INPUT_PULLUP); // Generator Sense INPUT
pinMode(ch3, INPUT_PULLUP); // FLOW switch sense INPUT
pinMode(ch4, OUTPUT); // Reset OUTPUT
pinMode(ch5, OUTPUT); // Choke OUTPUT
pinMode(ch6, OUTPUT); // Self OUTPUT
pinMode(ch7, OUTPUT); //Grid Contactor OUTPUT
pinMode(ch8, OUTPUT); // Generator Contactor OUTPUT
digitalWrite(ch6, HIGH); //Turn off Self contactor
digitalWrite(ch7, HIGH); //Turn off Grid contactor
digitalWrite(ch8, HIGH); // Tunn off Generator contactor
lcd.begin(16,2);
int i = 1;
int flag=0;
}
void loop()
{
lcd.setCursor(0,0); //Start at character 0 on line 1
lcd.print ("FLOW");
if ((digitalRead(ch3) == LOW))
{ (flag=1); //
lcd.setCursor(6,0); //Start at character 0 on line 1
lcd.print ("DET");}
if ((digitalRead(ch3) == LOW))
{ //
lcd.setCursor(10,0); //Start at character 0 on line 1
lcd.print ("ON ");}
if ((digitalRead(ch3) == HIGH))
{
lcd.setCursor(10,0); //Start at character 0 on line 1
lcd.print ("OFF");}
Serial.println(flag);
if ( (flag==1) && (digitalRead(ch1) == LOW)) //FLOW stich on and wapda on
{ digitalWrite(ch8, HIGH) ; // OFF Generator Contactor
Serial.println("Flow Detected + Shutting Generator contacto off");
delay (500);
digitalWrite(ch7, LOW) ; // ON Grid Contactor
Serial.println("Flow Detected + Latching KEL");
lcd.setCursor(0,2); //Start at character 0 on line 1
lcd.print ("K-OK-ON ");}