Push button input flickering from EM interference?

Hey there.
Working on a project and having a problem with the Arduino Uno.

Right now, there are 4 buttons and 4 leds. When each button is pressed, the corresponding led is supposed to come on (the buttons are functioning as on/off switches).

The first three buttons work as desired but the 4th button input is reacting to electromagnetic interference. When I bring my hand near the circuit, the 4th led flashes uncontrollably. The Arduino seems to think that the button is being pressed rapidly. It even flashes when I touch the surface that the board is sitting on.

The code and circuitry is identical for all of the buttons and leds. The fact that only one of them is malfunctioning leads me to believe it is an electrical problem.

I have attempted to fix the issue by enabling the pullup resistor on the 4th button input pin; this does stop the flickering but then the button is unresponsive.

I have attached my Arduino code and my circuit design, hoping someone can help.

Thanks!

ArduinoOn:OffButton.ino (3.3 KB)

 pinMode(BUTTON_1_PIN, INPUT);
  pinMode(BUTTON_2_PIN, INPUT);
  pinMode(BUTTON_3_PIN, INPUT);
  pinMode(BUTTON_4_PIN, INPUT_PULLUP);

The internal pull-up resistor on pin 4 is "fighting" the pull-down resistor.

...I'd actually recommend ditching the pull-down resistors in favor of enabling the built-in internal pull-ups. Then wire the switch to ground [u]like this[/u].

It reverses the logic so pushing the button "overpowers" the pull-up resistor making the input low. So, normally you have to reverse your software logic. But if your "state change" sensing works, that might not be necessary. I didn't study your code so I'm not sure.

Change all to INPUT_PULLUP

Wire button to connect pin to Gnd when pressed, nothing else.

if (digitalRead(pinX) == LOW){
// button was pressed, do something
}
else {
// button is released
}

I have modified the circuit and enabled the pullup resistor, but the fourth led still is not responding. Now I cannot get the system to react to the fourth button. I have checked multiple sources to make sure my code and wiring are correct.

The confusing thing is that the other buttons work in their previous config (with physical resistor) even if the pullup resistor is enabled on that input. But the fourth button will not react no matter what.

We finally fixed it, we used the pull-up resistor and turns out a pin in our breadboard wasn’t responsive and it was just a breadboard problem.