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