#include <Stepper.h>
#include <Bounce2.h>

const int stepsPerRevolution = 2038;

Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
Bounce debouncer1 = Bounce();
Bounce debouncer2 = Bounce();
Bounce debouncer3 = Bounce();
unsigned long debounceTime = 50;

void setup()
{
  myStepper.setSpeed(15);
  debouncer1.attach(21, INPUT_PULLUP);
  debouncer2.attach(20, INPUT_PULLUP);
  debouncer3.attach(19, INPUT_PULLUP);
}

void loop()
{
  debouncer1.update();
  debouncer2.update();
  debouncer3.update();

  int state1 = debouncer1.read();
  int state2 = debouncer2.read();
  int state3 = debouncer3.read();
  
  static unsigned long oldTime1 = 0;
  static unsigned long oldTime2 = 0;
  static unsigned long oldTime3 = 0;
  static int oldState1 = HIGH;
  static int oldState2 = HIGH;
  static int oldState3 = HIGH;
  
  unsigned long currentTime = millis();
  
  if (currentTime - oldTime1 > debounceTime)
  {
    if (state1 == LOW && state1 != oldState1)
    {
      myStepper.step(200);
      delay(1000);
      myStepper.step(-200);
    }
    oldState1 = state1;
    oldTime1 = currentTime;
  }
  
  if (currentTime - oldTime2 > debounceTime)
  {
    if (state2 == LOW && state2 != oldState2)
    {
      myStepper.step(-200);
      delay(1000);
      myStepper.step(200);
    }
    oldState2 = state2;
    oldTime2 = currentTime;
  }
  
  if (currentTime - oldTime3 > debounceTime)
  {
    if (state3 == LOW && state3 != oldState3)
    {
      myStepper.step(200);
      delay(1000);
      myStepper.step(-200);
    }
    oldState3 = state3;
    oldTime3 = currentTime;
  }
}
$abcdeabcde151015202530fghijfghij
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT