 int PWMSpeed[6] = {0, 0, 0, 0, 0, 0};
 boolean slopeRise1 = 1, slopeFall1 = 0, slopeRise2 = 1, slopeFall2 = 0, slopeRise3 = 1, slopeFall3 = 0, slopeRise4 = 1, slopeFall4 = 0;
 byte timeCounter = 0;
+volatile unsigned int timeOfLastMessageReceived = 0;
 unsigned long startingTime = 0;
 int slopeCounter1 = 0, slopeCounter2 = 0, slopeCounter3 = 0, slopeCounter4 = 0;
 byte Kp = 0;

#define NO_PRINT 0
#define PRINT_SPEED 1
#define Something

//mXeY - silnik X, pin enkodera Y
#define m1e1 23

    String buffer = "";
    buffer.reserve(10);
    String buffer2 = "";
    String decomposedMessage[7];
    for(int i = 0; i<7; i++)
    {
      decomposedMessage[i].reserve(10);
      decomposedMessage[i] = "";
    }
      
    buffer2.reserve(10);
    String bufferMotor = "";
    bufferMotor.reserve(10);
    for (int i=0; i<spaceBar; i++)
      buffer += inputString.charAt(i);

    for(int indexPtr = 0, segmentPtr = 0; indexPtr<(inputString.length()-1) && segmentPtr<7; indexPtr++)
    {
      decomposedMessage[segmentPtr] +=  inputString.charAt(indexPtr);
      if(inputString.charAt(indexPtr+1) == ' ')
      {
        segmentPtr++; 
        indexPtr++;
      }
    }

//    spaceBar = inputString.indexOf(' ');
//    for (int i=spaceBar+1; i<(inputString.length()-1); i++)
//      buffer2 += inputString.charAt(i);

    if(decomposedMessage[0] == "Set")
    {
      timeOfLastMessageReceived = millis();
      for (int i=0; i<6; i++)
      {
        int buffer = decomposedMessage[i+1].toInt();
        if(buffer > 0)
          u[i] = min(buffer, mios);
        else
          u[i] = max(buffer, -mios);
      }

      for (int i=0; i<6; i++)
      {
        Serial.print(u[i]);
        Serial.print(", ");
      }
      Serial.println("");
    }

    else if (buffer == "SetKp")
    {
      Kp = buffer2.toInt();
