I have a problem with my Bluetooth module on my Arduino, I am trying to do a door that opens with a button in an application in the phone but when I press the button in the app the door doesn't move.
#include <SoftwareSerial.h>
#include <Servo.h>
int mover;
int mover2;
Servo servoMotor1;
Servo servoMotor2;
char rxChar;
SoftwareSerial BTserial(10, 11);
void setup(){
Serial.begin(9600);
Serial.println("Bluetooth test program");
pinMode (4,INPUT);//Fin de carrera 1
pinMode (2,INPUT);//Fin de carrera 2
mover=90; //0 Abrir 180 Cerrar 60-120 Velocidades
mover2=150;//motor Cerradura
servoMotor1.attach(8);//Motor Pin8
servoMotor2.attach(9);//Motor Pin9
BTserial.begin(9600);
BTserial.println("Bluetooth test program");
}
void loop() {
int lectura;
int lectura2;
servoMotor1.write(mover);
servoMotor2.write(mover2);
lectura=digitalRead(4);//fin de carrera
lectura2=digitalRead(2);//fin de carrera
if (Serial.available())
{
BTserial.write(Serial.read());
}
if (BTserial.available())
{
Serial.write(BTserial.read());
char rxChar = BTserial.read();
}
if(rxChar=='a'){
Serial.print("60 Grados");
mover=60;
}
if(rxChar=='b'){
Serial.print("120 Grados");
mover=120;
}
if (lectura==LOW and mover==120){
mover=90;//motor frena
mover2=30;//Motor Cerradura Cerrado
}
if (lectura2==LOW and mover==60){
mover=90;//motor frena
}
}
when I press the button the console returns "⸮"