Arduino LilyPad with Button Board Issues

Hello Everyone,
I have a Lilypad for a project, and recently purchased a lilypad button board (LilyPad Button Board - DEV-08776 - SparkFun Electronics). I wanted to come here to ask advice on how to hook this board up. Previous push buttons I've used have had three connections: power, ground, digital i/o (used as a toggle, or some function). However, this board only has two connections, and so I'm not entirely sure how to use it.

I have an RGB LED project which has several "modes" i.e. the device can display different configurations of LEDs and colors. Right now, to switch between the modes, I have to manually reprogram it. What I'd like to do is have this push button "cycle" through the different modes. Currently, I have it wired such that one end of the push button is connected to ground, and the other to on of the digital I/O pins. I write HIGH to that pin every loop cycle, and check to see if it has gone low (i.e. the switch has closed and the digital I/O pin has now been grounded).

I was thinking something like this, but I can't seem to make it work. What I'm looking for is advice on the overall idea/framework/architecture.

Thank you in advance!

Chris

//Define button pin
const int  buttonPin = 2;    // the pin that the pushbutton is attached to

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status
int buttonPushCounter = 1;

//Set max modes
int maxModes = 3;

void setup() {
  
   // initialize the button pin as a input:
   // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);  

  //initialize the buttonPin as output
  digitalWrite(buttonPin, HIGH);  
  
}


void loop(){
    // read the state of the pushbutton value:
    buttonState = digitalRead(buttonPin);
  
    // check if the pushbutton is pressed.
    // if it is, the buttonState is HIGH:
    if (buttonState == HIGH) {     

    } 
    else {
      
      buttonPushCounter++;
      if(buttonPushCounter>maxModes)
      {
        buttonPushCounter = 1;
      }
    }
   
   switch (buttonPushCounter) {
     case 1:
       mode1();
     break;
     
     case 2:
       mode2();
     break;
     
     case 3:
       mode3();
 
     break;
     
   }
  
}

I have it wired such that one end of the push button is connected to ground, and the other to on of the digital I/O pins.

This is right, but the input will be LOW when the button is pushed.

// initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);  

  //initialize the buttonPin as output
  digitalWrite(buttonPin, HIGH);

The comment is wrong. If you write a HIGH to an input, you enable the internal pullup resistor which in your case, with the switch wired to GND and an input, is a proper way to interface a switch.

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
The way the switch is wired it is pulled HiGH when not pressed and LOW when pressed.

Attached is how I wire my switches.
At some point you will also have to deal with switch bounce. This can be done with hardware or software.

groundfungus,
Thank you very much for your reply! I am going to give this a try and see what happens.

Chris