Internal Pullup

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

Hi,
No its not debounce because PIN8 (trigger pin) never get in contact with - (Negative)

The program get triggers from unknow source probably from nearby wire , that is the reason I used internal_pullup

 if ((digitalRead(ch3) == LOW)) 
    { (flag=1); //

Normally it happens when PIN 1 get LOW, but this is not certain. It happens after some random minutes when PIN 1 gets low which cause PIN 3 to get low as well. In my code there is no such thing than PIN 1 will get PIN 3 low.

If you are getting unexpected pulses from a sensor, how do you think that changing the software will help? Shouldn't you be investigating and measuring the hardware?

Hi,
There is no such sensor which could cause malfunctions, all are digital pins read and write.
Pin 3 gets negative from unknown source specially after some random minutes when pin 1 gets low.

In code there is nothing that triggers to get pin 3 low when Pin 1 gets low.
Need to mention that Mega is closely packed in a box where all pins and relays are tightly packed. Could this be reason? If so than I suppose could have been solved by internal_pullup.

Complete code is below:

#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 ");} 
   
   
  if (  (flag==1) && (digitalRead(ch1) == HIGH)) //FLOW stich on and wapda off
          {
                  digitalWrite(ch7, HIGH) ; // OFF Wapda Contactor 
                  
          lcd.setCursor(0,2); //Start at character 0 on line 1
   lcd.print ("K-  -OFF");} 
      
    
    

  if ((flag==1) && (i<6) && (digitalRead(ch2) == HIGH) )  
  {     digitalWrite(ch5, LOW) ; // CHOKE
    Serial.println("Flow Detected + Choke");
  
        digitalWrite(ch4, LOW) ; // Reset ON
        Serial.println("Flow Detected + Heater ON");
                delay (5000);
        digitalWrite(ch4, HIGH) ; // Reset OFF
                
        Serial.println("Flow Detected + Heater OFF");
        
        digitalWrite(ch6, LOW) ; // SELF ON
        Serial.println("Flow Detected + SELF ON");
        lcd.setCursor(9,1); //Start at character 0 on line 1
   lcd.print ("       "); 
      lcd.setCursor(15,1); //Start at character 0 on line 1
      lcd.print (i); 
         delay (5000);
      lcd.setCursor(15,1); //Start at character 0 on line 1
      lcd.print (" "); 
                
        digitalWrite(ch6, HIGH) ; // SELF OFF
        
        Serial.println("Flow Detected + SELF OFF");
         lcd.setCursor(15,1); //Start at character 0 on line 1
   lcd.print (" "); 
        
       i=(i+1); 
       Serial.println(i);
           }

 if ((flag==1) && (digitalRead(ch1) == HIGH)    && (digitalRead(ch2) == LOW)) //FLOW stich on and wapda off and generator on
    {     digitalWrite(ch7, HIGH) ; // OFF Wapda Contactor 
    Serial.println("Flow Detected + Shutting Wapda Contactor Off");
    delay (500);
    digitalWrite(ch8, LOW) ; // ON Genserator Contactor 
  lcd.setCursor(9,2); //Start at character 0 on line 1
   lcd.print ("G-OK-ON");
     i=(1);
    Serial.println("Flow Detected + Latching Generator On");
     }
     
 if ((flag==1) && (digitalRead(ch2) == LOW) && (digitalRead(ch8) == HIGH))
 
 {lcd.setCursor(9,2); //Start at character 0 on line 1
  i=(1);
 lcd.print ("G-OK-OF");} 
     
 
 if ((flag==1) && (digitalRead(ch2) == HIGH) && (digitalRead(ch8) == HIGH))
  {lcd.setCursor(9,2); //Start at character 0 on line 1
 lcd.print ("G- -OF ");} 
 
     
     
     

 if ((flag==1) && (digitalRead(ch2) == HIGH)) //FLOW stich on and wapda off and generator on
    {     digitalWrite(ch8, HIGH) ; }// OFF Generator Contactor }


}

saleemsadruddin:
Hi,
There is no such sensor which could cause malfunctions, all are digital pins read and write.
Pin 3 gets negative from unknown source

That could damage the pin. Please cease to ignore the requests for real information, or you will be ignored.

Hi
I provided complete code, and giving all information. There are no sensors. In code you can see that.

Its a very simple code.

Pin 3 needs to go low to do task
Pin 3 getting negative signal from unknown source. How?

My subject is internal pullup but no one is talking on this issue.

Already given complete code, please see. I am not damaging pin.

aarg:
That could damage the pin. Please cease to ignore the requests for real information, or you will be ignored.

Hi,
I will make schematic and would upload.

Have you thought of using a lower resistance external pull-up resistor, like 1K? That should help suppress noise at the inputs. I suspect that a "Grid Contactor" and a "Generator Contactor" will both produce a LOT of electrical noise.

When you say "Pin 1" and "Pin 3" and "Pin 8" are you talking about "ch1" (Pin 6) and "ch3" (Pin 8) and getting the names and pin numbers confused? "ch1" through "ch8" are LOUSY names for pin numbers. If you used descriptive names your code would be easier to read.

#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity


const byte GridSenseInPin =  6; //Grid Sense INPUT
const byte GeneratorSenseInPin =  7; // Generator Sense INPUT
const byte FLOWSenseInPin =  8; // FLOW switch sense INPUT
const byte ResetOutPin =  9; // Reset OUTPUT
const byte ChoketOutPin =  10; // Choke OUTPUT
const byte SelfOutPin = 11; // Self OUTPUT
const byte GridContactorOutPin = 22; //Grid Contactor OUTPUT
const byte GeneratorContactorOutPin = 33; // Generator Contactor OUTPUT
int i = 1;
boolean RunningFlag = false;

void setup()
{
  Serial.begin(9600);

  pinMode(GridSenseInPin, INPUT_PULLUP); //Grid Sense INPUT
  pinMode(GeneratorSenseInPin, INPUT_PULLUP); // Generator Sense INPUT
  pinMode(FLOWSenseInPin, INPUT_PULLUP); // FLOW switch sense INPUT
  pinMode(ResetOutPin, OUTPUT); // Reset OUTPUT
  pinMode(ChoketOutPin, OUTPUT); // Choke OUTPUT
  pinMode(SelfOutPin, OUTPUT); // Self OUTPUT
  pinMode(GridContactorOutPin, OUTPUT); //Grid Contactor OUTPUT
  pinMode(GeneratorContactorOutPin, OUTPUT); // Generator Contactor OUTPUT

  digitalWrite(SelfOutPin, HIGH); //Turn off Self contactor
  digitalWrite(GridContactorOutPin, HIGH); //Turn off Grid contactor
  digitalWrite(GeneratorContactorOutPin, HIGH); // Tunn off Generator contactor

  lcd.begin(16, 2);
}

void loop() {
  lcd.setCursor(0, 0); //Start at character 0 on line 1
  lcd.print ("FLOW");

  if (digitalRead(FLOWSenseInPin) == LOW)
  {
    RunningFlag = true;

    lcd.setCursor(6, 0);
    lcd.print ("DET");

    lcd.setCursor(10, 0);
    lcd.print ("ON ");
  } else {
    lcd.setCursor(10, 0);
    lcd.print ("OFF");
    //  Uh...  Maybe set RunningFlag to false?
    //  RunningFlag = false;
  }

  Serial.println(RunningFlag);

  // DO NOTHING FURTHER UNTIL RunningFlag == true
  if (RunningFlag == false)
    return;

  // Running

  if (digitalRead(GridSenseInPin) == LOW) //FLOW stich on and wapda on
  {
    digitalWrite(GeneratorContactorOutPin, HIGH) ; // OFF Generator Contactor

    Serial.println("Flow Detected + Shutting Generator contactor off");
    delay (500);
    digitalWrite(GridContactorOutPin, LOW) ; // ON Grid Contactor
    Serial.println("Flow Detected + Latching KEL");

    lcd.setCursor(0, 2);
    lcd.print ("K-OK-ON ");
  } else {
    //FLOW stich on and wapda off
    digitalWrite(GridContactorOutPin, HIGH) ; // OFF Wapda Contactor

    lcd.setCursor(0, 2);
    lcd.print ("K-  -OFF");
  }


  if ((i < 6) && (digitalRead(GeneratorSenseInPin) == HIGH) )
  { digitalWrite(ChoketOutPin, LOW) ; // CHOKE
    Serial.println("Flow Detected + Choke");

    digitalWrite(ResetOutPin, LOW) ; // Reset ON
    Serial.println("Flow Detected + Heater ON");
    delay (5000);
    digitalWrite(ResetOutPin, HIGH) ; // Reset OFF

    Serial.println("Flow Detected + Heater OFF");

    digitalWrite(SelfOutPin, LOW) ; // SELF ON
    Serial.println("Flow Detected + SELF ON");
    lcd.setCursor(9, 1);
    lcd.print ("       ");
    lcd.setCursor(15, 1);
    lcd.print (i);
    delay (5000);
    lcd.setCursor(15, 1); //Start at character 0 on line 1
    lcd.print (" ");

    digitalWrite(SelfOutPin, HIGH) ; // SELF OFF

    Serial.println("Flow Detected + SELF OFF");
    lcd.setCursor(15, 1); //Start at character 0 on line 1
    lcd.print (" ");

    i += 1;
    Serial.println(i);
  }

  if ((digitalRead(GridSenseInPin) == HIGH)    && (digitalRead(GeneratorSenseInPin) == LOW)) //FLOW stich on and wapda off and generator on
  {
    digitalWrite(GridContactorOutPin, HIGH) ; // OFF Wapda Contactor
    Serial.println("Flow Detected + Shutting Wapda Contactor Off");
    delay (500);
    digitalWrite(GeneratorContactorOutPin, LOW) ; // ON Genserator Contactor
    lcd.setCursor(9, 2); //Start at character 0 on line 1
    lcd.print ("G-OK-ON");
    i = 1;
    Serial.println("Flow Detected + Latching Generator On");
  }

  if (digitalRead(GeneratorContactorOutPin) == HIGH) {
    if (digitalRead(GeneratorSenseInPin) == LOW)

    {
      lcd.setCursor(9, 2); //Start at character 0 on line 1
      i = 1;
      lcd.print ("G-OK-OF");
    } else  {
      lcd.setCursor(9, 2); //Start at character 0 on line 1
      lcd.print ("G- -OF ");
    }
  }

  if (digitalRead(GeneratorSenseInPin) == HIGH) //FLOW stich on and wapda off and generator on
  {
    digitalWrite(GeneratorContactorOutPin, HIGH) ;
  }// OFF Generator Contactor
}

johnwasser:
Have you thought of using a lower resistance external pull-up resistor, like 1K? That should help suppress noise at the inputs. I suspect that a "Grid Contactor" and a "Generator Contactor" will both produce a LOT of electrical noise.

When you say "Pin 1" and "Pin 3" and "Pin 8" are you talking about "ch1" (Pin 6) and "ch3" (Pin 8) and getting the names and pin numbers confused? "ch1" through "ch8" are LOUSY names for pin numbers. If you used descriptive names your code would be easier to read.

#include <LiquidCrystal_I2C.h>

#include <Wire.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity

const byte GridSenseInPin =  6; //Grid Sense INPUT
const byte GeneratorSenseInPin =  7; // Generator Sense INPUT
const byte FLOWSenseInPin =  8; // FLOW switch sense INPUT
const byte ResetOutPin =  9; // Reset OUTPUT
const byte ChoketOutPin =  10; // Choke OUTPUT
const byte SelfOutPin = 11; // Self OUTPUT
const byte GridContactorOutPin = 22; //Grid Contactor OUTPUT
const byte GeneratorContactorOutPin = 33; // Generator Contactor OUTPUT
int i = 1;
boolean RunningFlag = false;

void setup()
{
 Serial.begin(9600);

pinMode(GridSenseInPin, INPUT_PULLUP); //Grid Sense INPUT
 pinMode(GeneratorSenseInPin, INPUT_PULLUP); // Generator Sense INPUT
 pinMode(FLOWSenseInPin, INPUT_PULLUP); // FLOW switch sense INPUT
 pinMode(ResetOutPin, OUTPUT); // Reset OUTPUT
 pinMode(ChoketOutPin, OUTPUT); // Choke OUTPUT
 pinMode(SelfOutPin, OUTPUT); // Self OUTPUT
 pinMode(GridContactorOutPin, OUTPUT); //Grid Contactor OUTPUT
 pinMode(GeneratorContactorOutPin, OUTPUT); // Generator Contactor OUTPUT

digitalWrite(SelfOutPin, HIGH); //Turn off Self contactor
 digitalWrite(GridContactorOutPin, HIGH); //Turn off Grid contactor
 digitalWrite(GeneratorContactorOutPin, HIGH); // Tunn off Generator contactor

lcd.begin(16, 2);
}

void loop() {
 lcd.setCursor(0, 0); //Start at character 0 on line 1
 lcd.print ("FLOW");

if (digitalRead(FLOWSenseInPin) == LOW)
 {
   RunningFlag = true;

lcd.setCursor(6, 0);
   lcd.print ("DET");

lcd.setCursor(10, 0);
   lcd.print ("ON ");
 } else {
   lcd.setCursor(10, 0);
   lcd.print ("OFF");
   //  Uh...  Maybe set RunningFlag to false?
   //  RunningFlag = false;
 }

Serial.println(RunningFlag);

// DO NOTHING FURTHER UNTIL RunningFlag == true
 if (RunningFlag == false)
   return;

// Running

if (digitalRead(GridSenseInPin) == LOW) //FLOW stich on and wapda on
 {
   digitalWrite(GeneratorContactorOutPin, HIGH) ; // OFF Generator Contactor

Serial.println("Flow Detected + Shutting Generator contactor off");
   delay (500);
   digitalWrite(GridContactorOutPin, LOW) ; // ON Grid Contactor
   Serial.println("Flow Detected + Latching KEL");

lcd.setCursor(0, 2);
   lcd.print ("K-OK-ON ");
 } else {
   //FLOW stich on and wapda off
   digitalWrite(GridContactorOutPin, HIGH) ; // OFF Wapda Contactor

lcd.setCursor(0, 2);
   lcd.print ("K-  -OFF");
 }

if ((i < 6) && (digitalRead(GeneratorSenseInPin) == HIGH) )
 { digitalWrite(ChoketOutPin, LOW) ; // CHOKE
   Serial.println("Flow Detected + Choke");

digitalWrite(ResetOutPin, LOW) ; // Reset ON
   Serial.println("Flow Detected + Heater ON");
   delay (5000);
   digitalWrite(ResetOutPin, HIGH) ; // Reset OFF

Serial.println("Flow Detected + Heater OFF");

digitalWrite(SelfOutPin, LOW) ; // SELF ON
   Serial.println("Flow Detected + SELF ON");
   lcd.setCursor(9, 1);
   lcd.print ("       ");
   lcd.setCursor(15, 1);
   lcd.print (i);
   delay (5000);
   lcd.setCursor(15, 1); //Start at character 0 on line 1
   lcd.print (" ");

digitalWrite(SelfOutPin, HIGH) ; // SELF OFF

Serial.println("Flow Detected + SELF OFF");
   lcd.setCursor(15, 1); //Start at character 0 on line 1
   lcd.print (" ");

i += 1;
   Serial.println(i);
 }

if ((digitalRead(GridSenseInPin) == HIGH)    && (digitalRead(GeneratorSenseInPin) == LOW)) //FLOW stich on and wapda off and generator on
 {
   digitalWrite(GridContactorOutPin, HIGH) ; // OFF Wapda Contactor
   Serial.println("Flow Detected + Shutting Wapda Contactor Off");
   delay (500);
   digitalWrite(GeneratorContactorOutPin, LOW) ; // ON Genserator Contactor
   lcd.setCursor(9, 2); //Start at character 0 on line 1
   lcd.print ("G-OK-ON");
   i = 1;
   Serial.println("Flow Detected + Latching Generator On");
 }

if (digitalRead(GeneratorContactorOutPin) == HIGH) {
   if (digitalRead(GeneratorSenseInPin) == LOW)

{
     lcd.setCursor(9, 2); //Start at character 0 on line 1
     i = 1;
     lcd.print ("G-OK-OF");
   } else  {
     lcd.setCursor(9, 2); //Start at character 0 on line 1
     lcd.print ("G- -OF ");
   }
 }

if (digitalRead(GeneratorSenseInPin) == HIGH) //FLOW stich on and wapda off and generator on
 {
   digitalWrite(GeneratorContactorOutPin, HIGH) ;
 }// OFF Generator Contactor
}

Hi,
Yes I know bit messy code.
But do you mean adding 1K pull up resistor along with internal pullup? This will make 1+10 = 11 K?
Correct me If I am wrong.

Secondly, I think my error is

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity

and it should be

LiquidCrystal_I2C lcd(0x27, 16, 2); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity

Scheme attached

saleemsadruddin:
Hi,
Yes I know bit messy code.
But do you mean adding 1K pull up resistor along with internal pullup? This will make 1+10 = 11 K?
Correct me If I am wrong.

You are wrong. If you add an additional/external pullup it will be in parallel with the internal pullup.
The final resistance for parallel resistors is not the sum of the two resistors.
When using two resistors it will the product/sum of the two resistance values.
Also I'm not sure where the 10 comes from in your math above.
The internal pullup resistance on an AVR pin is about 50k so 1x50/(1+50) = 50/51 or .980k or 980 ohms.

Secondly, I think my error is

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity

and it should be

LiquidCrystal_I2C lcd(0x27, 16, 2); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity

Are you having LCD issues? The two constructors shown above are for two different LCD libraries.
If you used the incorrect one, you would get compilation errors.
If the pin mapping parameters in the first one were incorrect, it would compile but not work.
If you are looking for a hd44780 lcd library, I'd recommend my hd44780 library.
It will auto detect everything so you don't have to enter any configuration parameters in the constructor.

Scheme attached

If that is your actual wiring, then you have not grounded the relay board, the LCD module, or buttons since they go over the breadboard with a floating ground.
You also have not provided power to the LCD or the relay board since there is no power going to the breadboard.
When grounds are floating, odd things can happen.
And for sure neither the relays, the LCD or the buttons would work.

H/W and s/w at the embedded level are VERY precise. It requires strict attention to details and using very precise and accurate terminology.

Saying things like "pin 3" when you are not using Arduino digital pin 3
and "Pin 3 gets negative from unknown source"

Are VERY confusing since from a technical perspective they don't make sense.

The term "negative" in that context would mean negative voltage but you may not have actually meant that and then you are not using pin 3.

You need to very precise and accurate with the information you communicate to people, otherwise it creates confusion and wastes time.

--- bill

Hi,
I will re-write code, and will correct scheme and re-wire hardware.
Hope this would solve, and will post here outcomes.