I'm trying to interface my mega 2560 with a matlab. I just have to move two servo motors based on values sent by matlab. Unfortunately I have had zero luck and am unable to debug. Could someone look at the code and maybe lead me towards the problem?[Arduino][http://pastebin.com/Pg5xb5h6][Matlab][http://pastebin.com/chQ2K3p6]

Hi, Im new about the arduino language. I have tried control the LED by using the matlab through Arduino, it work well to me, but cannot control even move the servo motor as i refer to the arduino forum the previous forum about arduino matlab servo. There are my steps and code in order to control and interface.1.dowload the arduino i/o support package and installed it.2.connect the arduino to PC via ubs port3.dowload and install the arduino software and 'upload' the adiosrv into arduino duemilanove (also try in romeo) board4.type arduino in the matlab and it connect successful.5.and then type "a=arduino('COM8')", "a.servoAttach(1)"and "a.servoWrite(1,50)" to move the servo motor 1(pin 9) from 0 to 50 degree.

but it seem does not work at all.my question are:1.is there any steps that i miss out?

2.any software is required others than what i mention above?

3.the romeo or the duemilanove that assign to "a.servoAttach(1)" is represented pin 9 and "a.servoAttach(2)"

You need to send more data. You need to send which servo the data is for as well as the data for the servo.

Then, you read two bytes of data - servo # and servo val - and move the corresponding servo. And, hope like hell no serial data ever gets lost. Don't forget that you need to wait for two or more bytes, not one or more, too.

myservoa.attach(6); //the pin for the servoa control myservob.attach(7); //the pin for the servob control myservoc.attach(8); //the pin for the servoc control myservod.attach(9); //the pin for the servod control Serial.println("multi-servo-delimit-test-dual-input-11-22-12"); // so I can keep track of what is loaded}

void loop() {

//expect single strings like 700a, or 1500c, or 2000d, //or like 30c, or 90a, or 180d, //or combined like 30c,180b,70a,120d,