The extra serial ports have their own pins. The use of those ports will not interfere with regular Serial (USB) or the Servo library.
Then i have an entierly different problem.
Here's whats happening,Whenever i write to the servo while bluetooth is connected(eg:section A in the code), the my phone disconnects to the connection to the bluetooth, and i have to reconnect again, The first command i send works , then the phone disconnects, heres a code:
#include <Servo.h>
#include <HardwareSerial.h>
Servo FlameServo;
void setup() {
// put your setup code here, to run once:
Serial1.begin(9600); //bluetooth
FlameServo.attach(35);
FlameServo.write(0); //servo
Serial.begin(19200);
}
char state;
int x,y;
void loop() {
while (Serial1.available()) {
state = Serial1.read();
if (state == 'A') { //servo left
delay(5);
if (Serial1.read() == '#') {
FlameServo.write(90); //command runs, but bluetooth disconnects after this,
delay(100);
}
}
if (state == 'S') { //spray water
delay(5);
if (Serial1.read() == '#')
Serial.println("Spra");
}
if (state == 'D') { //Servo Right
delay(5);
if (Serial1.read() == '#'){
Serial.println("d");
FlameServo.write(180); //command runs, but bluetooth disconnects after this,
delay(100);
}
}
delay(5);
}
}
Juraj:
what library?
I think I misunderstood the problem, i was talking about teh HardwareSerial libary, but I dont think using that would help, im guessing the problem is with the app im using? its this:https://play.google.com/store/apps/details?id=com.nudge.me.JSF