HC-05 module using Arduino Mega 2560 to run very basic LED ON, LED OFF program.
On my Win 10 box I can send/receive to/from the HC-05 using Microsoft's Bluetooth Serial Terminal app and turn the LED on/off. However, when I try to use RealTerm on the same port (Device Manager shows the HC-05 on port 27), RealTerm will open the port, but the HC-05 isn't receiving any characters sent from RealTerm.
I'm reasonably competent (practicing EE for 50+ years), but this has me stumped. Any ideas?
TIA,
Frank
#define ledPin 13
char state = 0;
unsigned long loopcount = 0;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(18, OUTPUT); //TX1
pinMode(19, INPUT_PULLUP); //RX1
digitalWrite(ledPin, LOW);
Serial.begin(115200);
Serial1.begin(9600); // Default communication rate of the Bluetooth module
}
void loop()
{
if (Serial1.available() > 0)
{ // Checks whether data is coming from the serial port
//Serial.println("Got a character");
state = Serial1.read(); // Reads the data from the serial port
Serial.print("received "); Serial.print(state); Serial.println(" from bluetooth");
loopcount = 0;
}
else
{
if (loopcount > 1000000)
{
loopcount = 0;
Serial.println("Nothing Yet...");
}
else
{
loopcount++;
}
}
if (state == '0') {
digitalWrite(ledPin, LOW); // Turn LED OFF
Serial1.println("LED: OFF"); // Send back, to the phone, the String "LED: ON"
state = 0;
}
else if (state == '1') {
digitalWrite(ledPin, HIGH);
Serial1.println("LED: ON");;
state = 0;
}
if (Serial.available() > 0)
{
char c = Serial.read();
Serial.print("Received "); Serial.println(c);
Serial1.print(c);
}
}
