Arduino Uno - Send a serial message when button pressed.

Hi all.
Sorry for my bad english, i speak french.

Today i wan't to send message when a button is pressed but if i use the sketch:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(2, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly
   if (digitalRead(2) == HIGH) {
         Serial.println("1");
   }
}

In the serial i have 20-30x "1"

I want to have just one "1", what can i do plz ?

The change should be detected. That means a variable is needed to remember the previous change.
This is the state change example : http://www.arduino.cc/en/Tutorial/StateChangeDetection

Sorry that no one has answered your other question yet ( RFID RC522 - Work 2-3 seconds - Sensors - Arduino Forum ).

Thank you for your answer !

For my first post, i have found the problem :slight_smile: