Using Serial Monitor to control 2 servos

This is the code that I have to control a servo, but if I had a second servo, I don’t understand how to add it into the program and how I would write it in the serial monitor. The first set of code is where I have one servo that works from 0-90 degrees and the second set was my attempt of adding in a second servo but I got stuck and now I am here.

First Code:

#include <Servo.h>

const unsigned int MOTORX_PIN = 9;
const unsigned int MOTOR_DELAY = 15;
const unsigned int SERIAL_DELAY = 5;
const unsigned int BAUD_RATE = 9600;

Servo servo_x;

void setup() {
Serial.begin(BAUD_RATE);
servo_x.attach(MOTORX_PIN);
delay(MOTOR_DELAY);
servo_x.write(1);
delay(MOTOR_DELAY);
}

void loop(){
const int MAX_ANGLE = 3;

char degrees[MAX_ANGLE + 1];

if(Serial.available()){
int i = 0;
while(Serial.available() && i < MAX_ANGLE) {
const char c = Serial.read();
if (c != -1 && c != ‘\n’)
degrees[i++] = c;
delay(SERIAL_DELAY);
}
degrees = 0;

  • Serial.print(degrees);*
  • Serial.println(" degrees. ");*
  • servo_x.write(atoi(degrees));*
  • delay(MOTOR_DELAY);*
  • }*
    }
    **Second Code: **
    #include <Servo.h>
    const unsigned int MOTORX_PIN = 6;
    const unsigned int MOTORY_PIN = 7;
    const unsigned int MOTOR_DELAY = 15;
    const unsigned int SERIAL_DELAY = 5;
    const unsigned int BAUD_RATE = 9600;
    String readString, servo_1, servo_2;
    Servo servo_x;
    Servo servo_y;
    void setup() {
  • Serial.begin(BAUD_RATE);*
  • servo_x.attach(MOTORX_PIN);*
  • servo_y.attach(MOTORY_PIN);*
  • delay(MOTOR_DELAY);*
  • servo_x.write(1);*
  • servo_y.write(2);*
  • delay(MOTOR_DELAY);*
    }
    void loop(){
  • const int MAX_ANGLE = 3;*
  • char degrees[MAX_ANGLE + 1];*
  • if(Serial.available()){*
  • int i = 0;*
  • while(Serial.available() && i < MAX_ANGLE) {*
  • const char c = Serial.read();*
  • if (c != -1 && c != ‘\n’)*
  • degrees[i++] = c;*
  • delay(SERIAL_DELAY);*
  • }*
    _ degrees = 0;_
    * Serial.print(degrees);*
    * Serial.println(" degrees. ");*
    * servo_x.write(atoi(degrees));
    servo_y.write(atoi(degrees));
    delay(MOTOR_DELAY);
    _
    }_
    _
    }*_

…and that’s why you have to use code tags.