user40014: I have just got a new pair of HC-05 Bluetooth modules. I am working on a simple project. I'm trying to move two servo motors using two potentiometers. I followed a simple tutorial to move one servo, and it worked successfully.
How to make the same thing with 2 potentiometers and two servos?
UPDATE:
I have successfully managed to write down something that get to read values from two potentiometers, but I'am still facing problems with the slave part.
Can't figure out the problem. 
(Master)
//Master
int potValuePins[] = { A0, A1 };
void setup() {
  Serial.begin(9600); // Default communication rate of the Bluetooth module
   for (auto pin : potValuePins) {
     pinMode(pin, INPUT);
   }
}

void loop() {
 for (auto pin : potValuePins) {
   Serial.write(pin); // Send the pin number
   Serial.write(analogRead(pin)); // Send the pin value with a trailing 
 newline as a delimiter
   int value=analogRead(pin);
   Serial.print(" Pin is: ");
   Serial.print(pin);
   Serial.print("\t");
   Serial.print("Value is: ");
   Serial.println(value);
   }
 }

(Slave)
//Slave
#include <Servo.h>
Servo myServo1;
Servo myServo2;

void setup() {
Serial.begin(9600);
myServo1.attach(9);
myServo2.attach(10);
}

void loop() {
if (Serial.available()) {
 char input[3];
 Serial.readBytes(input, 2);
 int pin = input[0];
 int angle = input[1];
 Serial.print("the pin:");
 Serial.print(pin);
 Serial.print("\t");
 Serial.print("the angle:");
 Serial.println( angle);

 switch (pin) {
  case A0:
    myServo1.write(angle);
    break;
  case A1:
    myServo2.write(angle);
    break;
  default:
    Serial.println("Unknown value");
    break;
   }
  }
 }


user27653: Looking at the example you linked to, the "communication" between the two ends is just writing a (byte) value between 0 and 255, and reading that on the other end.
One simple (out of many possibilities) to extend this to handle a set of two is just to send 2 bytes in sequence, with the first byte being an identifier of which servo you are denoting. 
Where the example master code shows:
// Reading the potentiometer
potValue = analogRead(A0);
int potValueMapped = map(potValue, 0, 1023, 0, 255);
Serial.write(potValueMapped); // Sends potValue to servo motor

You instead write:
// Reading the potentiometer 1
pot1Value = analogRead(A1);
int pot1ValueMapped = map(pot1Value, 0, 1023, 0, 255);
Serial.write(1);
Serial.write(pot1ValueMapped); // Sends pot1Value to servo motor

// Reading the potentiometer 2
pot2Value = analogRead(A0);
int pot2ValueMapped = map(pot2Value, 0, 1023, 0, 255);
Serial.write(2);
Serial.write(pot2ValueMapped); // Sends pot2Value to servo motor

And on the slave side, where the example has:
if (Serial.available() > 0) { // Checks whether data is comming from the serial port
  state = Serial.read(); // Reads the data from the serial port
}
// Controlling the servo motor
myServo.write(state);

You have to separate out the two possible choices:
if (Serial.available() > 0) {
  servo_num = Serial.read();
}
if (Serial.available() > 0) {
  state = Serial.read();
}

switch (servo_num) {
  case 1:
    myServo1.write(state);
    break;
  case 2:
    myServo2.write(state);
    break;
}

Note that you'll also have to declare the servo_num variable, and instantiate two of the Servo objects. The code above is just a guide.
The simple expansion above is not robust, as it's possible that the 2nd byte is not received by the time the 2nd Serial.read() is called, and then that byte would be caught next time around the loop() by the first Serial.read() call and you'd be out of sync. But hopefully, this shows the general concept of how to start developing a protocol that is more complex than just single values.
Edit: What's probably happening is the system is getting out of sync. As I noted, it's not a robust protocol, but I think you may now understand the idea.
You can re-map the servo values to go from 2-255, rather than 0-255, and set the servo_num to either 0 or 1. In the slave, if you get a number <2, then it's a servo selector, otherwise it's a servo value. but then you lose the ability to set the servo to 0 or 1.
Also, you may want to space out the master sending the values, as you are likely sending data faster than the servo could respond. You could put a delay(100) or something in the loop() function, or change your code to use a millis()-based state machine (see the "BlinkWithoutDelay" Arduino example).

40014: <p>I have just got a new pair of HC-05 Bluetooth modules. I am working on a simple project. I'm trying to move two servo motors using two potentiometers. I followed <a href="http://howtomechatronics.com/tutorials/arduino/how-to-configure-pair-two-hc-05-bluetooth-module-master-slave-commands/" rel="nofollow noreferrer">a simple tutorial</a> to move one servo, and it worked successfully.</p>

<p>How to make the same thing with 2 potentiometers and two servos?</p>

<p>UPDATE:</p>

<p>I have successfully managed to write down something that get to read values from two potentiometers, but I'am still facing problems with the slave part.
Can't figure out the problem. </p>

<p>(Master)</p>



<pre class="lang-cpp prettyprint-override"><code>//Master
int potValuePins[] = { A0, A1 };
void setup() {
  Serial.begin(9600); // Default communication rate of the Bluetooth module
   for (auto pin : potValuePins) {
     pinMode(pin, INPUT);
   }
}

void loop() {
 for (auto pin : potValuePins) {
   Serial.write(pin); // Send the pin number
   Serial.write(analogRead(pin)); // Send the pin value with a trailing 
 newline as a delimiter
   int value=analogRead(pin);
   Serial.print(" Pin is: ");
   Serial.print(pin);
   Serial.print("\t");
   Serial.print("Value is: ");
   Serial.println(value);
   }
 }
</code></pre>

<p>(Slave)</p>

<pre class="lang-cpp prettyprint-override"><code>//Slave
#include &lt;Servo.h&gt;
Servo myServo1;
Servo myServo2;

void setup() {
Serial.begin(9600);
myServo1.attach(9);
myServo2.attach(10);
}

void loop() {
if (Serial.available()) {
 char input[3];
 Serial.readBytes(input, 2);
 int pin = input[0];
 int angle = input[1];
 Serial.print("the pin:");
 Serial.print(pin);
 Serial.print("\t");
 Serial.print("the angle:");
 Serial.println( angle);

 switch (pin) {
  case A0:
    myServo1.write(angle);
    break;
  case A1:
    myServo2.write(angle);
    break;
  default:
    Serial.println("Unknown value");
    break;
   }
  }
 }
</code></pre>
 27653: <p>Looking at the example you linked to, the "communication" between the two ends is just writing a (byte) value between <code>0</code> and <code>255</code>, and reading that on the other end.</p>

<p>One simple (out of many possibilities) to extend this to handle a set of two is just to send 2 bytes in sequence, with the first byte being an identifier of which servo you are denoting. </p>

<p>Where the example master code shows:</p>

<pre><code>// Reading the potentiometer
potValue = analogRead(A0);
int potValueMapped = map(potValue, 0, 1023, 0, 255);
Serial.write(potValueMapped); // Sends potValue to servo motor
</code></pre>

<p>You instead write:</p>

<pre><code>// Reading the potentiometer 1
pot1Value = analogRead(A1);
int pot1ValueMapped = map(pot1Value, 0, 1023, 0, 255);
Serial.write(1);
Serial.write(pot1ValueMapped); // Sends pot1Value to servo motor

// Reading the potentiometer 2
pot2Value = analogRead(A0);
int pot2ValueMapped = map(pot2Value, 0, 1023, 0, 255);
Serial.write(2);
Serial.write(pot2ValueMapped); // Sends pot2Value to servo motor
</code></pre>

<p>And on the slave side, where the example has:</p>

<pre><code>if (Serial.available() &gt; 0) { // Checks whether data is comming from the serial port
  state = Serial.read(); // Reads the data from the serial port
}
// Controlling the servo motor
myServo.write(state);
</code></pre>

<p>You have to separate out the two possible choices:</p>

<pre><code>if (Serial.available() &gt; 0) {
  servo_num = Serial.read();
}
if (Serial.available() &gt; 0) {
  state = Serial.read();
}

switch (servo_num) {
  case 1:
    myServo1.write(state);
    break;
  case 2:
    myServo2.write(state);
    break;
}
</code></pre>

<p>Note that you'll also have to declare the servo_num variable, and instantiate two of the Servo objects. The code above is just a guide.</p>

<p>The simple expansion above is <em>not</em> robust, as it's possible that the 2nd byte is not received by the time the 2nd <code>Serial.read()</code> is called, and then that byte would be caught next time around the <code>loop()</code> by the first <code>Serial.read()</code> call and you'd be out of sync. But hopefully, this shows the general concept of how to start developing a protocol that is more complex than just single values.</p>

<p><strong>Edit:</strong> What's probably happening is the system is getting out of sync. As I noted, it's not a robust protocol, but I think you may now understand the idea.</p>

<p>You can re-map the servo values to go from 2-255, rather than 0-255, and set the <code>servo_num</code> to either <code>0</code> or <code>1</code>. In the slave, if you get a number <code>&lt;2</code>, then it's a servo selector, otherwise it's a servo value. but then you lose the ability to set the servo to 0 or 1.</p>

<p>Also, you may want to space out the master sending the values, as you are likely sending data faster than the servo could respond. You could put a <code>delay(100)</code> or something in the <code>loop()</code> function, or change your code to use a <code>millis()</code>-based state machine (see the "BlinkWithoutDelay" Arduino example).</p>
