controllare motori stepper wifi

Ciao
sono finalmente riuscito a creare un controllo efficace wireless,grazie al OSC(Open Sound Control)
dei motori stepper ho un Arduino yun,ma funziona come un Leonardo(la parte Linux è partita)uno shield motor Adafruit v2 e lo shield wifi di arduino.
Ho creato uno slider con valori -255 255 e un pulsante on off,perciò il motore Nema 17 si muove ,con un buon controllo in real time.
Ora vorrei un piccolo aiuto,anzi due;-)
1:vorrei implementare 4 pulsanti per cambiare gli step(MICRO, INTERLAVE, SINGLE, DOUBLE)
2:vorrei poter registrare (con un pulsante) dei parametri per renderli ripetibili,es accel , velocità, step decellerazione come se fosse una timeline sequencer.
Se qualcuno mi può aiutare ne sarei grato.
Il progetto mi serve per uno slide-dolly video.

Magari può servire a qualcuno il mio sketch…

#include <Arduino.h>
#include <OSCBundle.h>
#include <WiFi.h>
#include <WiFiUdp.h>
#include <AccelStepper.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"


Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 1);
// you can change these to SINGLE, DOUBLE or INTERLEAVE or MICROSTEP!

void forwardstep2() {  
  myMotor->onestep(BACKWARD, MICROSTEP);
}
void backwardstep2() {  
  myMotor->onestep(FORWARD, MICROSTEP);
}
AccelStepper stepper2(forwardstep2, backwardstep2);

int status = WL_IDLE_STATUS;
char ssid[] = "saibai"; //  your network SSID (name)
char pass[] = "";    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;            // your network key Index number (needed only for WEP)


int serverPort  = 8000; //TouchOSC (incoming port)
int destPort = 9000;    //TouchOSC (outgoing port)
int ledPin =  13; 
int runState = LOW;


char packetBuffer[255]; //buffer to hold incoming packet


WiFiUDP Udp;

void setup() {
  //Initialize serial and wait for port to open:
  AFMS.begin(); 
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
// check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }
// attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
  status = WiFi.begin(ssid);
// print your local IP address:
  Serial.println("Connected to wifi");
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

delay(1000);
  }
 
  Udp.begin(serverPort);
  stepper2.setMaxSpeed(1000.0);
  stepper2.setAcceleration(1000.0);
 

  pinMode(ledPin, OUTPUT);
  }


void loop() {





  if(runState==LOW) {
    //Serial.println("Motor On");
   
    stepper2.runSpeed();
  }

  else {
    //Serial.println("Motor Off");
    stepper2.disableOutputs();
    myMotor->release();
  }
  
    //process received messages
    OSCMsgReceive();
  
}

void OSCMsgReceive(){
  OSCMessage msgIN;
  int size;
  if((size = Udp.parsePacket())>0){
    while(size--)
      msgIN.fill(Udp.read());
    if(!msgIN.hasError()){
      msgIN.route("/OnOff/toggle1",toggleOnOff);
      msgIN.route("/Fader/Value",funcValue);
    
      
    }
  }
}

void toggleOnOff(OSCMessage &msg, int addrOffset){
  runState = (boolean) msg.getFloat(0);
  OSCMessage msgOUT("/OnOff/toggle1");

  digitalWrite(ledPin, runState);

  msgOUT.add(runState);

  Serial.print("runState = ");
  Serial.println(runState);

  runState = !runState;     // toggle the state from HIGH to LOW to HIGH to LOW ...

  //send osc message back to controll object in TouchOSC
  //Local feedback is turned off in the TouchOSC interface.
  //The button is turned on in TouchOSC interface whe the conrol receives this message.
  Udp.beginPacket(Udp.remoteIP(), destPort);
  msgOUT.send(Udp); // send the bytes
  Udp.endPacket(); // mark the end of the OSC Packet
  msgOUT.empty(); // free space occupied by message
}





int faderValue = 0;

void funcValue(OSCMessage &msg, int addrOffset ){

  OSCMessage msgOUT("/Fader/Value");

  faderValue = msg.getFloat(0);

  stepper2.setSpeed(faderValue);

  Serial.print("faderValue = ");
  Serial.println(faderValue);

  msgOUT.add(faderValue);

  Udp.beginPacket(Udp.remoteIP(), destPort);
  msgOUT.send(Udp); // send the bytes
  Udp.endPacket(); // mark the end of the OSC Packet
  msgOUT.empty(); // free space occupied by message
}