I am new to processing and this is my first post to the forum. I would like to control multiple servos (30+) using processing via the lynxmotion ssc-32. I have searched the forum and online and have not found a lot of helpful info on how to to communicate with the ssc-32 directly through processing. By connecting the ssc-32 to a stand alone arduino I can make a servo sweep 180 degrees using this arduino sketch:
int servo1 = 0;
void setup() {
Serial.begin(115200);
int servo1 = 0;
}
void loop()
{
servo1 = 500;
Serial.print("#1 P");
Serial.print(servo1);
Serial.print(" T");
Serial.println(1000);
delay(1200);
servo1 = 2000;
Serial.print("#1 P");
Serial.print(servo1);
Serial.print(" T");
Serial.println(1000);
delay(1200);
}
It seemed logical that I would be able to do the same thing with something like this in processing:
import processing.serial.*;
Serial myPort; // Create object from Serial class
int servo1 = 0;
void setup()
{
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 115200);
}
void draw() {
servo1 = 500;
myPort.write("#1 P");
myPort.write(servo1);
myPort.write(" T");
myPort.write(1000);
myPort.write("\n"); // because there is no .writeln in processing?
delay(1200);
servo1 = 2000;
myPort.write("#1 P");
myPort.write(servo1);
myPort.write(" T");
myPort.write(1000);
myPort.write("\n"); // because there is no .writeln processing?
delay(1200);
}
But this does not work. The green light is flashing on the ssc-32 so I know data is getting through but the servo is not moving. I have noticed when I exchange the Serial.println(1000); with Serial.print(1000); in the arduino sketch that I get the same outcome with the arduino as with processing. The green led is flashing on the ssc but no servo movement. From this I deduce that that the ssc needs a new line between messages but there is no .writeln() in processing. As you can see by the sketch I attempted to use "\n" but this doesn't seem to work. Any help or ideas would be greatly appreciated.