Ok, I am now able to get it responding to the software, but it only works well with single characters. Is it just how I am formatting the strings, or can the Arduino only receive one character at a time through the Serial? It only seems to work if I use single characters.
Arduino:
while (Serial.available()>0){
String MotorCode = Serial.readString();
if (MotorCode.substring(0) == "C"){
Claw.write(map(MotorCode.substring(1,-1).toInt(), 0, 180, 0, 180));
digitalWrite(LED_BUILTIN,HIGH);
}
else {
digitalWrite(LED_BUILTIN,LOW);
}
}
Processing:
void draw() {
getUserInput();
background(selectcontrol,700,400);
println("You are now in Control >:)");
//send a list that consists of the joint's name and, position(and direction) to the serial for the arduino
if(clawarmselect == true){ //control claw arm with right stick
println("Selecting the claw arm to control, use the right stick to control");
portmessage = "A"+str((int)selectcontrol);
println(portmessage);
port.write(portmessage);
}
if(elbowselect == true){ //control elbow with button and control right stick
println("Selecting the elbow to control, use the right stick to control");
portmessage = "B"+str((int)selectcontrol);
println(portmessage);
port.write(portmessage);
}
if(clawgrab == true){ //close claw
println("Claw Closing");
port.write("C90");
}
if(clawrelease == true){ //open claw
println("Claw Opening");
port.write("C180");
}