Problems with pushbutton

I've been using Arduino for a while and recently I started with NANO, and it gave me a strange error. When I hook up a push button to it, it is extremely sensitive (I touch the button without pressing it and it sends signal to arduino). I'am wiring it to 5v-D2. I searched on the internet, tried puting resistors, configuring the inpin as PULLUP, but nothing. I also tried with diferent pushbuttons. Any help?

You need a pulldown - ie a resistor to ground - if you've wired one end of the swirch to +5.

Suggest 10k

Allan

Thanks Allan, you really saved my day

The better answer would be to Wire your switch between the pin and ground so you can use the internal pull-up.

Delta_G:
The better answer would be to Wire your switch between the pin and ground so you can use the internal pull-up.

Agreed.
Must add: this makes the button active LOW and inactive HIGH, so swap your logic states when reading the buttons.