Button ground when arduino held

Hi everyone, I'm struggling hard on something I thought would be so simple. I have a button that makes the on board LED turn on when I press it. I have it set on a pin and INPUT_PULLUP.

My problem:

The button activates when I pick up my Arduino. I think I'm grounding it.

If the default of my button is high and when I press the button it becomes LOW, how do I account for when I touch or hold my Arduino and make it so that it doesn't bring my button to LOW?

I'm hoping for a coding fix as opposed to a hardware fix but any insight is very much appreciated.

I couldn't find anything online.

Thank you in advance.

ex08_orButtons2.ino (560 Bytes)

Most of the Arduino boards are susceptible to that effect and the answer is not to handle them when they are live or you are testing something.

You could mount the board on something non conductive so picking it up by that will not affect the running of the board.
You could wear an antistatic wrist strap.

As for fixing it in code you could try some debounce which might help a little but may be tricky to get the timing correct.

Bob.