I want to connect a HC-05 Bluetooth module to an ESP8266 and use the input received from the bluetooth module in an if/else statement.
When doing this I can receive data from bluetooth to the serial, but then I cannot use the Arduino IDE serial to println characters. Why doesn't println work anymore for the Serial, if i .begin the bluetoothserial connection?
Tried different baud rates, different Pins
#include <SoftwareSerial.h>
SoftwareSerial BTserial(1, 3); // RX | TX
String reading;
void setup()
{
// Arduino IDE serial monitor
Serial.begin(9600);
Serial.println("hoihoi");
// HC-05 default serial speed for AT mode is 38400
BTserial.begin(9600);
// Wait for hardware to initialize
delay(1000);
// Print debug string
}
void loop()
{
Serial.println("hoi");
// Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTserial.available())
{
String reading = (String)BTserial.read();
Serial.println(reading);
//input from mobile is 1 AKA 10% PWM
if(reading == "1"){
Serial.println("Input from Bluetooth is 1");
}
//input from mobile is 2 AKA 100% PWM
else if(reading == "2") {
Serial.println("Input from Bluetooth is 2");
}
//input from mobile is 3 AKA 0% PWM
else if(reading == "3") {
Serial.println("Input from Bluetooth is 3");
}
}
}
I want to use the data received from the bluetooth module in and if/else statement and output it in the Serial.
However, currently I cannot print anything to the Serial. When I remove " BTserial.begin(9600);" I can output to the Serial.