Arduino picking up button presses on power up of the board

So I am starting to get into smd soldering. I thought I'll build myself a smd ovwn
I have a button on it that allows you to switch between reflow soldering and just preheating the board.

Occasionally I find when I plug usb pwr in, Arduino picks up button presses. I do have a 10k pull up on the switch input. So why am I experiencing this strange behaviour
 
This can happen if the input pin is floating briefly during power-up before the pull-up resistor fully stabilizes the logic level. Even with a 10k pull-up, there's still a short window during boot where noise or voltage instability might register as a press.


You might want to try a stronger pull-up (e.g., 4.7k or even 1k), or better yet, add a small capacitor (like 100nF) from the input pin to ground for some basic debounce and filtering. Also make sure your switch isn't bouncing or picking up stray signals during the USB plug-in.
 
Try to lower the pull-up value to 4.7k or even 1k for a stronger pull-up, which makes the pin less susceptible to noise.
You can also use the internal pull-up by defining the pin like this:
Code:
pinMode(buttonPin, INPUT_PULLUP);
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…