HC-05 bluetooth modules

Hi everyone,

I’m currently in the middle of a project where i need to control 5 servo’s with 5 potentiometers using the HC-05 bluetooth modules as a master and slave device. I coded them up on 1 Arduino Uno board and i got them working all fine and how I want it, I moved on to add the bluetooth modules and i can get one servo moving with the potentiometer but as soon as i add in a second servo with potentiometer it doesn’t work. it seems like i am getting conflicting data as the second potentiometer seems to be able to control the same servo as the first potentiometer. Just looking for some advice on what you think i am doing wrong. my wiring is TX to RX (pin 0) and RX to TX (pin 1) and then all the ground to ground and voltage to voltage and servos to pins. I have attached both the master and the slave code for the control of two servo below for you guys to look at.

MASTER:
int stateA1 = 0;
int stateA2 = 0;
int pot1Value = 0;
int pot2Value = 0;

void setup() {

Serial.begin(38400); // Default communication rate of the Bluetooth module
}
void loop() {
if(Serial.available() > 0){ // Checks whether data is comming from the serial port
stateA1 = Serial.read(); // Reads the data from the serial porta
stateA2 = Serial.read();
}
// Reading the potentiometer
pot1Value = analogRead(A0);
int pot1ValueMapped = map(pot1Value, 0, 1023, 0, 180);
Serial.write(pot1ValueMapped); // Sends potValue to servo motor
delay(10);

pot2Value = analogRead(A1);
int pot2ValueMapped = map(pot2Value, 0, 1023, 0, 180);
Serial.write(pot2ValueMapped); // Sends potValue to servo motor
delay(10);
}

SLAVE:

#include <Servo.h>

Servo myServo1;
Servo myServo2;
int stateA1 = 180;
int stateA2 = 180;

void setup() {

myServo1.attach(9);
myServo2.attach(8);
Serial.begin(38400); // Default communication rate of the Bluetooth module
}
void loop() {
if(Serial.available() > 0){ // Checks whether data is comming from the serial port
stateA1 = Serial.read(); // Reads the data from the serial port
stateA2 = Serial.read();

}
// Controlling the servo motor
myServo1.write(stateA1);
delay(0);
myServo2.write(stateA2);
delay(0);
}

 int pot1ValueMapped = map(pot1Value, 0, 1023, 0, 180);

What type is needed to store values in the range 0 to 180? Are you sure you don't need a long or a long long?

What type does Serial.write() take?

 delay(0);
 myServo2.write(stateA2);
 delay(0);

delay(0) is even dumber than delay()ing for any other length of time.

Why are you moving the servos if there is no new data?

How do you plan to deal with the fact that serial data is NOT guaranteed to be delivered?