False positives using "digitalRead" on Uno with 9V 1A power supply

Experiencing very random ghost like false positives with "digitalRead" when powering the Arduino Uno with a 9V 1A power supply. The code logic is sensing for a "HIGH" state on micro switches. The switches in this case are sitting silent and not touched. Current Arduino Uno configuration consists of 7 micro switches connected to pins 2 trough 8, 23 led's, several matrix and 7-segment led displays. All the micro switches have a pull down resistor of 10K from input to ground. When powering the Uno with a 5V USB (2000mA) supply or an alkaline 9V battery the micro switches do not create these false positives. Is there an issue with using a 1A 9V power supply or should the pull down resistance be increased? Please advise.

All the micro switches have a pull down resistor of 10K from input to ground.

You may or may not have the pull-down resistors wired correctly to prevent floating input pin condition. Can you draw out and post your exact wiring for the input pin, resistor, switch, voltage source for at least one of the switches.


Yes, change the switches - use the internal pullup resistors to hold the pin in a High state, and use the switch to connect the pin to ground; then act on the Low that is read:

in void setup:

pinMode(pinX, INPUT_PULLUP); // input with internal pullup (IDE 1.01 & later I think)

pinMode(pinX, INPUT);
digitalWrite(pinX, HIGH);  // enables internal pullup

in void loop:

if (digitalRead(pinX) == LOW){
// do some action

The wiring for a single switch is exactly as per image.
Again, I do not experience false positives when using a 9V battery or 5V USB power supply.

Your attempt to link to a webpage did not work. Try this: Reply, Additional Options, then browse to your file.

Perhaps your 9V 1A (wall supply) is not putting out clean 9V DC?

Let’s try an image attachment.
Perhaps the 9V supply as you mentioned is causing the problem.
Will try another to see if problem goes away.