const int button1Pin = 14;
const int button2Pin = 12;
const int ledPin = 2;
int button1State = 0;
int button2State = 0;
int currentStep =0;
int prestate1 =0;
int prestate2 =0;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(button1Pin, INPUT_PULLUP);
pinMode(button2Pin, INPUT_PULLUP);
Serial.begin(9600);
}
void loop()
{
button1State = digitalRead(button1Pin);
button2State = digitalRead(button2Pin);
// check if the pushbutton is pressed. If it is, then the buttonState is HIGH:
if (button1State == LOW && prestate1 == 0)
{
currentStep++;
Serial.println(currentStep);
prestate1 = 1;
}
else if(button1State == HIGH && prestate1 == 1)
{
currentStep--;
Serial.println(currentStep);
prestate1 = 0;
}
if (button2State == LOW && prestate2 == 0)
{
currentStep++;
Serial.println(currentStep);
prestate2 = 1;
}
else if(button2State == HIGH && prestate2 == 1)
{
currentStep--;
Serial.println(currentStep);
prestate2 = 0;
}
}