Need help with bounce.h

I am trying to implement the new bounce library but with no success.
The sketch below should mode a stepper for 24 pushes of the button.
But it doenst and i cant see why.

#include <Bounce.h>

const int StationPin = 12 ;    // Input for the station indicator switch

int MyStation = 0 ;            // Value where the bridge is standing
int i = 0;
int MyReady = false ;

Bounce StationSwitch = Bounce( 50 , StationPin ); 

void setup()
{
  // Set comunication baudrate to 115K 
  Serial.begin(115200);

  pinMode(StationPin, INPUT); 
}

void loop()
{
      MyReady = true;
      while(MyReady == true ) {
        i = 0;
        while(i != 24) { 
          StationSwitch.update();
          if( StationSwitch.read() == 1) {
            i++;
            MyStation++;
            Serial.println(i);
          } 
          else { Serial.println("STEP"); } // end if..else..
        } // end second while
        MyReady = false ;
        Serial.print("Reached position ");
        Serial.println(MyStation);
      } // end first while

}

Any help would be welcome.

Harry

The sketch below should mode a stepper for 24 pushes of the button.

What does this mean? There is nothing in the code to do anything with a stepper motor. With no code, I can't see how you expect a stepper to do anything but sit there looking pretty.

Here the stepper would move one step

          else { Serial.println("STEP"); } // end if..else..

I left that code out as it would be of no importance.
Until the button would be pressed the routine prints STEP to the outside world.

Harry

Did you look at the Bounce library?

class Bounce
{

public:
	// Initialize
  Bounce(uint8_t pin, unsigned long interval_millis );

You are using a 12 millisecond interval for the switch on pin 50.

  1. :astonished: Schame on me.
    I ported the code from de old Debounce lib.
    Thnxs