Muovere Passo passo tramite pulsante

Grazie BrainBooster e a tutti gli altri

XD XD XD XD siete dei mitiiiiiiiiiii!!! :grin: :grin: :grin:
Funzionaaaaaaaaaaaaaaa!!!!!!!!!!

Ora però siamo a metà del lavoro ,cioè quando premo il pulsante il motore gira verso destra quando lascio si ferma
Avendo un secondo pulsante sul pin 12 come posso far cambiare direzione?
Io fino adesso cambiavo lo stato di questa stringa rotateDeg(-1000, 0.7);da positivo a negatico togliendo ed inserendo la - davanti al 1000
Come potrei fare?
Grazie infinite

int DIR_PIN_M1 =3;  //7
int STEP_PIN_M1 =2; //5
int SLEEP = 6;      // PIN 12 = SLP
int DIR_PIN_M2 =3;
int STEP_PIN_M2 =2;

const int buttonPin = 10;  //Setting button number 1 to Pin 2
int buttonState = 0;   //Setting button state to off


void setup() {
  pinMode(DIR_PIN_M1, OUTPUT);
  pinMode(STEP_PIN_M1, OUTPUT);
  
  
} 

void loop(){

  //specifica numero giri e tempo di attesa
 
 
  if ( digitalRead(buttonPin) == 0) {
  rotateDeg(-1000, 0.7);
   delay(000);
}
}  

void rotateDeg(float deg, float speed){
  //rotate a specific number of degrees (negitive for reverse movement)
  //speed is any number from .01 -> 1 with 1 being fastest - Slower is stronger
  int dir = (deg > 0)? HIGH:LOW;
  digitalWrite(DIR_PIN_M1,dir); 

  int steps = abs(deg)*(1/0.225);
  float usDelay = (1/speed) *70;

  for(int i=0; i < steps; i++){
    digitalWrite(STEP_PIN_M1, HIGH);
    delayMicroseconds(usDelay); 

    digitalWrite(STEP_PIN_M1, LOW);
    delayMicroseconds(usDelay);
  }
  
  }
void rotate_M2(int steps, float speed){
  //rotate a specific number of microsteps (8 microsteps per step) - (negitive for reverse movement)
  //speed is any number from .01 -> 1 with 1 being fastest - Slower is stronger
  int dir = (steps > 0)? HIGH:LOW;
  steps = abs(steps);

  digitalWrite(DIR_PIN_M2,dir); 
  

  float usDelay = (1/speed) * 70;

  for(int i=0; i < steps; i++){
    digitalWrite(STEP_PIN_M2, HIGH);
    delayMicroseconds(usDelay); 

    digitalWrite(STEP_PIN_M2, LOW);
    delayMicroseconds(usDelay);
}

}[code*