RaspberryPi Serial with Arduino Servo controll

Hello all,
I am new to arduino, and my problem is that I am trying to control two servos that are attached to my arduino with a raspberry pi through usb serial.
I am able to control one servo with no problem. This code works fine.

#include <Servo.h>

int pos =0;
void setup()
{
  myservo.attach(5);
  Serial.begin(115200)
}
 void loop()
 {
  if (Serial.available()>0){
    pos = Serial.read();
  }
  myservo.write(pos)
 }

Here I am trying to control two servos by sending a character through serial to one of the servos with a value to move a servo. I have been stuck on this for days and need some help.

#include <Servo.h>
Servo servoX;
Servo servoY;

void setup()
{
  myservo.attach(5);
  Serial.begin(115200)
}
 void loop()
 {
  if (Serial.available()>0){
   char ch = Serial.read();
  if (ch == 'X'); 
  else if (ch == 'Y') ;
  }
  servoX.write('X'); // move to value that is assigned to X from serial
  servoY.write('Y'); // move to value that is assigned to Y from serial
 }
 if (ch == 'X');

Oops

servoX.write('X');

Can't see the point of writing a constant value to a servo. Did you mean to write the value of the variable "ch", or something mapped from it?

Something mapped from it

From the raspberry pi I would send X(180) through the serial to the arduino. The arduino will then wait for a character and then read its value.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. Look especially at the 3rd example and the parse example.

You could send the data for the two servos like this “<123, 97>”

…R

Thank you , but as a newbie I'm still at a lost. Has anyone done anything like this and can send me a code?

Much of the code you need is in the link I already gave you. Have you studied it?

You may also find some useful stuff in this Python - Arduino demo which was written prior to the code in the other link.

...R Planning and Implementing a Program