 #define SEL_B 31 //0 su 2
 #define BT_A A14 //0 premuto
 #define BT_B A8 //1 premuto
+#define SEL_Gp A5 //0 su G e 1 su p
 
 long muovi(char let, int vel, int posA, int posB, int posC = 0);
 long t0 = 0;
+long dd = 100;
+long tdd = 0;
+
+uint8_t channels[16] = {53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38};
 
 void setup() {
   pinMode(MAINSW, INPUT_PULLUP);

    {
      if (digitalRead(BT_A) == 0)  //premuto
      {
        Serial.println("motore B/D orario");
        ///////////////////////////
        Serial2.print("P 3000");
        Serial2.print('\r');
        delay(100);
        Serial2.print("p 0 10");
        Serial2.print('\r');
        delay(100);
        Serial2.print("G 3000");
        Serial2.print('\r');
        delay(100);
        Serial2.print("g 0 -10 0");
        Serial2.print('\r');
        ////////////////////////////
        delay(1000);
      }
      else if (digitalRead(BT_B) == 1)  //premuto
      {
        Serial.println("motore B/D antiorario");
        ///////////////////////////
        Serial2.print("P 3000");
        Serial2.print('\r');
        delay(100);
        Serial2.print("p 0 -10");
        Serial2.print('\r');
        delay(100);
        Serial2.print("G 3000");
        Serial2.print('\r');
        delay(100);
        Serial2.print("g 0 10 0");
        Serial2.print('\r');
        ////////////////////////////
        delay(1000);
      }
    }


    Serial2.print(payload);

    payload = "";

    payload += let;
