Control servos through app trouble

I have tried to make the code more consistent my using pos1 for myServo1 and pos2 for myServo2. See if this code is what you want for movements.

Speeds are controlled by both the delays in the .write() command in the for() loops as well as the refresh speeds controlled by the timer interrupts. See the source code for the Adafruit_SoftServo.h library for details.

If the increments in the for() loops occur significantly faster than the timer, the physical increments will be larger than expected and the motion might be jerky. I've set all the for loop increments at 15ms, and the timer updates the actual position every 20 ms. You may want to set the for() loop delays to greater than 20ms.

#include <Adafruit_SoftServo.h>
#include <SoftwareSerial.h>

#define SERVO1PIN 3
#define SERVO2PIN 4

#define TXPIN 0 //Connected to TX on HM-10
#define RXPIN 1 //Connected to RX on HM-10

int pos1 = 0; //position for servo1
int pos2 = 0; //position for servo2

SoftwareSerial Serial(0, 1); //RX|TX

Adafruit_SoftServo myServo1, myServo2;

void setup() {
  Serial.begin(9600);
  while (!Serial);
  // Set up the interrupt that will refresh the servo for us automagically
  OCR0A = 0xAF;            // any number is OK
  TIMSK |= _BV(OCIE0A);    // Turn on the compare interrupt (below!)

  myServo1.attach(SERVO1PIN);
  myServo2.attach(SERVO2PIN);   // Attach the servo to pin 0 on Trinket

  myServo1.write(12); //0?
  myServo2.write(12); //90?
}

void loop()
{
  if (Serial.available() > 0)
  {
    char w = Serial.read();

    if (w == 'a')
    {
      for (pos2 = 90; pos2 <= 102; pos2 += 1)
      {
        myServo2.write(pos2);
        delay(15);
      }

      for (pos1 = 0; pos1 <= 180; pos1 += 1)
      {
        myServo1.write(pos1);
        delay(15);
      }
      
      
      for (pos1 = 180; pos1 >= 0; pos1 -= 1)
      {
        myServo1.write(pos1);
        delay(15);
      }
    }

    if (w == 'z')
    {
      for (pos2 = 102; pos2 >= 90; pos2 -= 1)
      {
        myServo2.write(pos2);
        delay(15);
      }
    }
  }
}
// We'll take advantage of the built in millis() timer that goes off
// to keep track of time, and refresh the servo every 20 milliseconds
// The SIGNAL(TIMER0_COMPA_vect) function is the interrupt that will be
// Called by the microcontroller every 2 milliseconds
volatile uint8_t counter = 0;
SIGNAL(TIMER0_COMPA_vect) {
  // this gets called every 2 milliseconds
  counter += 2;
  // every 20 milliseconds, refresh the servos!
  if (counter >= 20) {
    counter = 0;
    myServo1.refresh();
    myServo2.refresh();//add this line for second servo
  }
}

I'm unsure about the initial servo positioning at 12, and whether the jumps to starting positions 90 and 0 will be a problem.

also, it seems when I run the program the " random data" seems to be something produced in the loop keeping a constant transmission of data without any input being implemented this seems to be the primary reason the program won't run correctly.

How do you know this? What do you mean by "constant transmission of data". What is the app you are using to send the bluetooth data?