Go Down

Topic: Arduino Uno - Send a serial message when button pressed. (Read 408 times) previous topic - next topic


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:

Code: [Select]
void setup() {
  // put your setup code here, to run once:
  pinMode(2, INPUT);

void loop() {
  // put your main code here, to run repeatedly
   if (digitalRead(2) == HIGH) {

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 ( http://forum.arduino.cc/index.php?topic=392295.0 ).


Thank you for your answer !

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

Go Up