Hello,
I have a problem connecting push button to arduino. I tried to connect the push button as shown in tutorial, and I wrote the code shown there, but I still have a problem with the push button, and I cant figure out what the problem is.
I used
this tutorial, and lots of other, I made the conections as shown there, but I still have a problem.
I made the conections as show in the picture

After that I wrote the code
const byte switchPin = 8;
void setup ()
{
Serial.begin (9600);
pinMode (switchPin, INPUT);
} // end of setup
void loop ()
{
if (digitalRead (switchPin) == HIGH)
{
Serial.println ("Push Button pressed");
delay (1000);
} // end if switchState is HIGH
else
{
Serial.println("Push button unpressed");
}
// other code here ...
} // end of loop
In this case serial monitor prints "Push Button pressed" , even I push the button, or not.
I tried connecting the button as shown in this figure

(I connected the leg to pin 11)
And even i press the button, It still prints "Push button unpressed"
I cant figure out what should be the problem.
I tried 4 push buttons, even a switch, but I still have same problem, like it cant read the state of pressed button. Should the push buttons been broken?
Should I tried a different push button, or i did something wrong in the code, or at connections?
I use Arduino Mega if it has any relevancy.
I used this kind of push button
http://postimg.org/image/ndvprzrx7/
Can someone help me with this issue? Thanks