Serial Reading and servo selection

hi, thanks for reply.

well i dont know if you are right.

this is what i send from matlab:

%% Arduino Servo Controller

arduino = serial('COM3','BaudRate',9600); % Set ComPort

fopen(arduino);
pause(0.01) % this is very important! arduino needs a little time to initialise the fopen command, because it resets it!

fwrite(arduino,201)

for i = 0:179  % Runs your servo from 0-179 degree
fwrite(arduino,i);
pause(0.02)
end

fclose(arduino);

delete(arduino)
clear arduino

this is my arduino code:

/*
Matlab-Arduino Servo Controller
*/

#include <Servo.h> 

//DECLARATION--------------------- 
Servo servo1;
Servo servo2;

//SETUP----------------------------
void setup() {
  
  Serial.begin(9600);
    
  servo1.attach(2);
  servo2.attach(3);
   
}

//LOOP--------------------------------
void loop() {

 if( Serial.available() ) 
    {
        int ser = Serial.read();
        
        if(ser == 201)
        {
        servo1.write(ser);
        }
        
        if(ser == 202)
        {
        servo2.write(ser);
        }
        
    }
  
}

I skipped the idea to use A,B, C....
instead i use 201, 202, 203....

when i just send the command 65 ie, my servo turns to 65 degree
so i dont have to send ascii commands.

how did you made the selection, if serial says 201, how do you send the other serial commands following to your servo?

---moe