Simple Pulse Counter

I am try to make Simple Pulse Counter using arduino uno board, so i find following link

where write
"Simple circuit that counts pulses, and reports it through the serial monitor.

This circuit counts pulses fed into pin 12. In this circuit, the pulses are generated by a push-button. The arduino checks the state of pin 12 every one millisecond. If pin 12 goes high, the arduino will count it as a pulse. The amount of pulses detected is displayed on the serial monitor. If pin 12 is held high, the arduino will count it as a single pulse."

And Following code use
/* Simple Pulse Counter

Counts digital pulses fed into pin 12. For reliability, the minimum pulse width is 1 millisecond.
If the signal is held high, the arduino will count it as one pulse.

*/

const int input = 12; // This is where the input is fed.
int pulse = 0; // Variable for saving pulses count.
int var = 0;

void setup(){
pinMode(input, INPUT);

Serial.begin(9600);
Serial.println(F("No pulses yet...")); // Message to send initially (no pulses detected yet).
}

void loop(){
if(digitalRead(input) > var)
{
var = 1;
pulse++;

Serial.print(pulse);
Serial.print(F(" pulse"));

// Put an "s" if the amount of pulses is greater than 1.
if(pulse > 1) {Serial.print(F("s"));}

Serial.println(F(" detected."));
}

if(digitalRead(input) == 0) {var = 0;}

delay(1); // Delay for stability.
}

But when i am upload sketch and click on serial monitor then i see automatic pulse counting start continue ( I am Not press switch ), its totally auto start pulse counting continue.

i can't understand where is the problem in code, please you find solution then tell me

What is connected to pin 12 ?
How is the input wired ?
Do you have a pulldown resistor in place ?

I am connect wire diagram See the image
And I am use 1k Resistor

thumbnail20161210-31527-14y0906.png

Those tactile buttons have a switched and non switched connections.

Connect the Arduino to diagonally opposed corners of the button rather than along one edge as your diagram shows. You will be guaranteed to pick up the switch legs.

7a7829decdd4b936e8ceb34da15c3dc5237bad91.png

Hello, Thanks for your help, now its working perfect. Thank you so much.