function nServosMove(H)

globalVar;

disp(' ');
nServos = input('N Servos to Move: ');
if isempty(nServos)
    nServos = 1;
end

ID = zeros(1,10);
Q = zeros(1,10);

for i= 1:nServos
    ID(1,i) = input('Servo ID [1 6]: ');
    while (ID(1,i) ~= [1:6])
    	ID(1,i) = input('Servo ID [1 6]: ');
    end
    
    if (ID(1,i) == 3)
        Q(1,i) = input('  Pos [-10 40]º: ');
        while (Q(1,i) ~= [-10:40])
            Q(1,i) = input('  Pos [-10 40]º: ');
        end
    else if (ID(1,i) == 1)
            Q(1,i) = input('  Pos [-30 0]º: ');
            while (Q(1,i) ~= [-30:0])
                Q(1,i) = input('  Pos [-30 0]º: ');
            end
        else if (ID(1,i) == 5)
                Q(1,i) = input('  Pos [-40 40]º: ');
                while (Q(1,i) ~= [-40:40])
                    Q(1,i) = input('  Pos [-40 40]º: ');
                end
            else
                Q(1,i) = input('  Pos [-90 90]º: ');    % restantes servos
                while (Q(1,i) ~= [-90:90])
                    Q(1,i) = input('  Pos [-90 90]º: ');
                end
            end
        end
    end
    Q(1,i) = round((((Q(1,i)+ANGLE_MAX)*VAL_ANGLE_RANGE)/ANGLE_RANGE)+VAL_ANGLE_MIN);
end

Texe = input('Time (s): ');
while (Texe ~= [0:0.01:5])
    Texe = input('Time (s): ');
end
ID(1,nServos+1) = 100;
Q(1,nServos+1) = Texe*100;

% par ou impar
if(nServos==1 || nServos==3 || nServos==5 || nServos==7)
   Tramas = (nServos+1)/2;
else if(nServos==2 || nServos==4 || nServos==6 || nServos==8)
    Tramas = nServos/2+1;
    ID(1,nServos+2) = 200;      % para preencher o espaço 10
    end
end

for i = 1:Tramas
    param1 = ID(1,i);
    param2 = bitand(Q(1,i),MASK_HIGH) / 256;
    param3 = bitand(Q(1,i),MASK_LOW);
    param4 = ID(1,i+1);
    param5 = bitand(Q(1,i+1),MASK_HIGH) / 256;
    param6 = bitand(Q(1,i+1),MASK_LOW);
    sendServo(H,Tramas,N_SERV,param1,param2,param3,param4,param5,param6);
end

% Leitura do tempo e posição do primeiro servo ---------------
posArray = zeros(1,800);
t = zeros(1,800);

return1 = 0;

pause(Texe-0.2);
i=0;
while (return1 ~= 1 || return2 ~= 2 || return3 ~= 3)
    i = i+1;
    [command,return1,return2,return3] = readServo(H);
    posArray(1,i) = return1*256 + return2;
    [command,return1,return2,return3] = readServo(H);
    t(1,i) = return1*256+return2;
end

disp(' ');
[command,return1,return2,return3] = readServo(H);       % Não preciso desta
N = (return1*256) + return2;                            % leitura porque
disp(['Movement with ', num2str(N), ' values.']);       % N = i-1;
% disp(['Movement with ', num2str(i-1), ' values.']);

for i=1:N
        posArray(1,i) = (((posArray(1,i)-VAL_ANGLE_MIN)*ANGLE_RANGE)/VAL_ANGLE_RANGE)+ANGLE_MIN;
end

posArray = posArray(1,1:N);
t = t(1,1:N);

figure
hold on
plot(t',posArray','*')
xlabel('Tempo (ms)')
ylabel('Posição (º)')
legend('First Servo')
axis([t(1,1) max(t) -100 100])
grid on
hold off

time = t(1,N-5)/1000;
disp(['Time from PIC: ', num2str(time), ' s']);

end