Button Project

Hey guys,
i really need your help i’m new to the arduino and programming in generel. I try to get my arduino micro to work with some buttons. The goal is if the button is pressed to send the information to serial. -i am using the button.h libary to be able to use isHold and onRelease. The buttons are connected to ground. I dont receve anything on serial. Heres my code:

#include <Button.h>

Button button2 = Button(2, LOW);
Button button3 = Button(3, LOW);
Button button4 = Button(4, LOW);
Button button5 = Button(5, LOW);
Button button6 = Button(6, LOW);
Button button7 = Button(7, LOW);
Button button8 = Button(8, LOW);
Button button9 = Button(9, LOW);
Button button10 = Button(10, LOW);
Button button11 = Button(11, LOW);
Button button12 = Button(12, LOW);

boolean holding2 = false;
boolean holding3 = false;
boolean holding4 = false;
boolean holding5 = false;
boolean holding6 = false;
boolean holding7 = false;
boolean holding8 = false;
boolean holding9 = false;
boolean holding10 = false;
boolean holding11 = false;
boolean holding12 = false;

void setup()
{
  Serial.begin(9600);
  pinMode(2, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
  pinMode(6, INPUT_PULLUP);
  pinMode(7, INPUT_PULLUP);
  pinMode(8, INPUT_PULLUP);
  pinMode(9, INPUT_PULLUP);
  pinMode(10, INPUT_PULLUP);
  pinMode(11, INPUT_PULLUP);
  pinMode(12, INPUT_PULLUP);
}

void loop()
{
  button2.listen();

  if (button2.onPress()) {
    Serial.print("<click:");
    Serial.print("20"); 
    Serial.print(">");  
  }

  if(!holding2 && button2.isHold()) {
    Serial.print("<hold:");
    Serial.print("20"); 
    Serial.print(">"); 
    holding2 = true;  
  }

  if(holding2 && button2.onRelease()) {
    Serial.print("<release:");
    Serial.print("20"); 
    Serial.print(">");
    holding2 = false;
  }


  button3.listen();

  if (button3.onPress()) {
    Serial.print("<click:");
    Serial.print("30"); 
    Serial.print(">");  
  }

  if(!holding3 && button3.isHold()) {
    Serial.print("<hold:");
    Serial.print("30"); 
    Serial.print(">"); 
    holding3 = true;  
  }

  if(holding3 && button3.onRelease()) {
    Serial.print("<release:");
    Serial.print("30"); 
    Serial.print(">");
    holding3 = false;
  }

  button4.listen();

  if (button4.onPress()) {
    Serial.print("<click:");
    Serial.print("40"); 
    Serial.print(">");  
  }

  if(!holding4 && button4.isHold()) {
    Serial.print("<hold:");
    Serial.print("40"); 
    Serial.print(">"); 
    holding4 = true;  
  }

  if(holding4 && button4.onRelease()) {
    Serial.print("<release:");
    Serial.print("40"); 
    Serial.print(">");
    holding4 = false;
  }

  button5.listen();

  if (button5.onPress()) {
    Serial.print("<click:");
    Serial.print("50"); 
    Serial.print(">");  
  }

  if(!holding5 && button5.isHold()) {
    Serial.print("<hold:");
    Serial.print("50"); 
    Serial.print(">"); 
    holding5 = true;  
  }

  if(holding5 && button5.onRelease()) {
    Serial.print("<release:");
    Serial.print("50"); 
    Serial.print(">");
    holding5 = false;
  }

  button6.listen();

  if (button6.onPress()) {
    Serial.print("<click:");
    Serial.print("60"); 
    Serial.print(">");  
  }

  if(!holding6 && button6.isHold()) {
    Serial.print("<hold:");
    Serial.print("60"); 
    Serial.print(">"); 
    holding6 = true;  
  }

  if(holding6 && button6.onRelease()) {
    Serial.print("<release:");
    Serial.print("60"); 
    Serial.print(">");
    holding6 = false;
  }

  button7.listen();

  if (button7.onPress()) {
    Serial.print("<click:");
    Serial.print("70"); 
    Serial.print(">");  
  }

  if(!holding7 && button7.isHold()) {
    Serial.print("<hold:");
    Serial.print("70"); 
    Serial.print(">"); 
    holding7 = true;  
  }

  if(holding7 && button7.onRelease()) {
    Serial.print("<release:");
    Serial.print("70"); 
    Serial.print(">");
    holding7 = false;
  }

  button8.listen();

  if (button8.onPress()) {
    Serial.print("<click:");
    Serial.print("80"); 
    Serial.print(">");  
  }

  if(!holding8 && button8.isHold()) {
    Serial.print("<hold:");
    Serial.print("80"); 
    Serial.print(">"); 
    holding8 = true;  
  }

  if(holding8 && button8.onRelease()) {
    Serial.print("<release:");
    Serial.print("80"); 
    Serial.print(">");
    holding8 = false;
  }

  button9.listen();

  if (button9.onPress()) {
    Serial.print("<click:");
    Serial.print("90"); 
    Serial.print(">");  
  }

  if(!holding9 && button9.isHold()) {
    Serial.print("<hold:");
    Serial.print("90"); 
    Serial.print(">"); 
    holding9 = true;  
  }

  if(holding9 && button9.onRelease()) {
    Serial.print("<release:");
    Serial.print("90"); 
    Serial.print(">");
    holding9 = false;
  }

  button10.listen();

  if (button10.onPress()) {
    Serial.print("<click:");
    Serial.print("100"); 
    Serial.print(">");  
  }

  if(!holding10 && button10.isHold()) {
    Serial.print("<hold:");
    Serial.print("100"); 
    Serial.print(">"); 
    holding10 = true;  
  }

  if(holding10 && button10.onRelease()) {
    Serial.print("<release:");
    Serial.print("100"); 
    Serial.print(">");
    holding10 = false;
  }

  button11.listen();

  if (button11.onPress()) {
    Serial.print("<click:");
    Serial.print("110"); 
    Serial.print(">");  
  }

  if(!holding11 && button11.isHold()) {
    Serial.print("<hold:");
    Serial.print("110"); 
    Serial.print(">"); 
    holding11 = true;  
  }

  if(holding11 && button11.onRelease()) {
    Serial.print("<release:");
    Serial.print("110"); 
    Serial.print(">");
    holding11 = false;
  }

  button12.listen();

  if (button12.onPress()) {
    Serial.print("<click:");
    Serial.print("120"); 
    Serial.print(">");  
  }

  if(!holding12 && button12.isHold()) {
    Serial.print("<hold:");
    Serial.print("120"); 
    Serial.print(">"); 
    holding12 = true;  
  }

  if(holding12 && button12.onRelease()) {
    Serial.print("<release:");
    Serial.print("120"); 
    Serial.print(">");
    holding12 = false;
  }
}

thanky in advance

Where did you get the Button library you are using? The version that is linked to from the playground doesn't have a listen() method.

This Button library https://github.com/carlynorama/Arduino-Library-Button

One thing I see right off the bat is you have no delay(X) in your main loop. Since your loop is really not all that big, it’s going to execute very, very fast… Your Serial.print() statements could cause the serial buffer to fill up and lock up the microcontroller until it’s reset. I recommend putting a delay(100); or something at the end of your loop so you don’t overload the serial buffer. That said, this probably doesn’t explain why your buttons don’t work. Maybe you wired them wrong?

Xpendable: One thing I see right off the bat is you have no delay(X) in your main loop. Since your loop is really not all that big, it's going to execute very, very fast... Your Serial.print() statements could cause the serial buffer to fill up and lock up the microcontroller until it's reset. I recommend putting a delay(100); or something at the end of your loop so you don't overload the serial buffer. That said, this probably doesn't explain why your buttons don't work. Maybe you wired them wrong?

i found the problem: it was a ground falt and now it works fine (: i will try putting the delay in the loop thans for the tipp (: