I have a problem with bluetooth module HC-05 and servos. If I type in bluetooth terminal 4,1 I want that servo1 turns 60 degrees 3 times. Briefly servo1 turns 60 degrees and then servo2 goes 180 and turns back and again servo1 turns 60 degrees and so on.
The bluetooth mixes the numbers. If I type "1" it gives me "49" and that's why the system is not working properly. How do I fix this data problem?
#include <Servo.h>
#include <SoftwareSerial.h>
Servo myservo1;
Servo myservo2;
long players, cards;
int pos1 = 0;
int pos2 = 0;
int servo;
int pos = 0;
int deal = 0;
SoftwareSerial BT(2,3);
void setup() {
Serial.begin(9600);
BT.begin(9600);
myservo1.attach(10);
myservo2.attach(11);
servo = 90;
}
void loop() {
if(BT.available()>0) {
players = BT.read();
cards = BT.read();
Serial.println(players);
Serial.print(cards);
pos = 180/(players-1);
for(deal = 0; deal < cards; deal++) {
for (pos1 = 0; pos1 <= 180 ; pos1 += pos ) {
delay(20);
myservo1.write(pos1);
for (pos2=0; pos2<=180 ; pos2 +=1){
myservo2.write(pos2);
delay(10);
}
for (pos2=180; pos2>=0 ; pos2 -=1){
myservo2.write(pos2);
delay(15);
}
}
for (pos1 <= 180; pos1 >= 0; pos1 -=1 ) {
pos2=0;
myservo1.write(pos1);
delay(10);
}
}
}
}