Getting rid of pin noise

Hi All,

I am very new to the Arduino and electronics in general, but have learned a great deal already. I have run into a problem with my first large scale project, and after delving through the code, it seems that my problem is physical.

It appears that my Arduino is randomly receiving inputs into my input pins from something as simple as me grabbing a wire. I believe the pins are reacting to extremely small fluctuations, or simply noise from other input pins. Is there a standard way to combat this (whether in code or something physical to consider)?

I found the debounce library helps, as this is my first post I can’tpost the link so give me a sec

there we go

hope that helps


Are the pins you're getting noise on already connected to something? If not then they'll float all over the place.


@Matte: Thanks for the link to the debounce library. I had found info on debouncing, but was having trouble implementing it. The library seems like a much easier way. I'll give that a shot.

@Andrew: The pins that are getting noise do have buttons connected to them. Basically, I am trying to make a Simon game, but when I push one button, I sometimes get inputs triggered as if I also pushed other buttons. That, or I get multiple inputs from a single button from one push.

The only issue I see with the debounce (unless I misunderstand how it works) is that I have already built some delay into the input (200ms I believe). I thought this would get rid of multiple inputs on its own, but it seemed to have not.

I read another post talking about putting a 0.1uF cap in line with the arduino somewhere to isolate noise issues. I didn't really understand it, but thought it might be a way to further ground the arduino in an attempt to reduce noise? Also, could the size of the breadboard I'm prototyping on be an issue? It is a pretty large breadboard.

Any suggestions would be great. I struggled a lot with getting the logic of the code worked out (has been a long time since I've programmed anything) and I'd hate to see this project die because of this issue.

I think this is the point where we ask you to post a diagram of exactly how you've got things connected up, and also to post your code so far. It's difficult to comment further without knowing what you've done.


This is a shot in the dark without seeing your wiring setup, but it sounds like you need to tie your input pins to ground with a pull-down resistor (10K should work). The idea is that the resistor holds the input pin low until the button closes and pulls it high. That way, while the button is open, the pin isn't floating and reacting to every little change around it. If your button is pulling the pin to low, then wire the resistor to 5V to pull it high instead.

I believe there is a way to accomplish this in software too. But I've never used the feature.

I'm new here, but the solution to your problem is pull-up or pull-down resistors, depending on preference. I believe there are some internal pull-ups on the Arduino, but I'm not sure. The resistor lets only some current flow, enough to either show a logical HIGH or a logical LOW, eliminating static's effect.

Use a 3K3 pull up resistor. It's better than a pull down.

Use a 3K3 pull up resistor. It's better than a pull down.

May I ask why pull up is better than pull down? I speak as a complete dunce when it comes to electronics...


It takes less current into an input to pull it up than the current you have to take out of an input to pull it down. Therefore you can use larger resistors, use less power and increase what is known as your "noise margin". That is, the amount of noise you can subject a system to before it starts to misbehave.

But most people just remember the rule

"pull up when you can and down if you must"

(I must admit I just made that up but it's good isn't it?)

Thanks for the explanation. Would I have found the "less current into an input to pull it up than the current you have to take out of an input to pull it down" bit in the ATMega168 datasheet? Mind you, even if it's in there I probably wouldn't understand it - 378 pages and I can read about 5 of them...


IIRC, the input pins on the atmel168 have internal pullups, which are activated when you write a HIGH to a pin configured as input.

Would I have found that bit in the ATMega168 datasheet

Well if you look on page 304 of the data sheet (ATMega168) it says the minimum voltage to be recognised as a logic one is 0.7V and the maximum voltage to be recognised as a logic zero is 0.2V so you can see there is some asymmetry in there, but no it is not something that you would expect to see a differently result for different chips it's just a general rule. When dealing with TTL logic circuits the asymmetry is even more pronounced in that a pull up resistor could be just about any value where as a pull down had to be less than about 270R due to the fact that you needed to sink current to below 0.7V for a zero on those parts.


the input pins on the atmel168 have internal pullups

Very true but these are weak pullups and for a more robust solution (less prone to interference) you can use stronger ones like 3K3 external like I recommended.