Consistent -1 return from BTSerial

This is a revival of an older item. Trying to connect HC-05 bluetooth device to Arduino sketch. the circuit is an "Instructables" tutorial on using HC-05 but their forum seems to not respond to this query.
The sketch code:

</>
#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11); // RX | TX
char AT_RMAAD_command[9] = {'A', 'T', '+', 'R', 'M', 'A', 'A', 'D', '\0'};
int pin9 = 9;
int pin6 = 6;
void setup() {
pinMode(6, OUTPUT); // pin 6 is for the LED (useless pilot light)
pinMode(9, OUTPUT); // Pin 9 will pull the HC-05 pin 34 ("key" pin)
// switch module to AT mode
digitalWrite(9, HIGH); // Setting pin to HIGH set the key to AT
digitalWrite(6, HIGH); // pilot light
Serial.begin(9600);
Serial.println("Enter AT commands:");
BTSerial.begin(38400); // HC-05 default speed in AT command more
}

void loop() {
/* coment everytHing from orig at-mode out
// Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTSerial.available())
Serial.write(BTSerial.read());

// Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
BTSerial.write(Serial.read());
*/
//

BTSerial.write(AT_RMAAD_command);
Serial.print("\tcommand is ");
Serial.print(AT_RMAAD_command);
Serial.print("\t");
BTSerial.write(Serial.read());
if (BTSerial.available())
Serial.write(BTSerial.read());
Serial.println(BTSerial.read());
delay(10000);
}
</>Preformatted text

The AT command codes are coding into the sketch as string arrays. The are written to the HC-05 but the return code constatnly is -1. The HC-05 is recognised to the extent that the unit's red LED flashses once the VCC is connected. Yes; the sketch does comple and upload. Serial is connected at 9600, while the BTSerial is connected at 38400.
Tom Kane , Vancouver, BC, Vanada

Installation and Troubleshooting is for Problems with the Arduino IDE itself NOT your project. It says so in the description of the section. Therefore I have moved your post here.

You might want to look at this How to get the best from this from this Forum before you proceed any further.

Read the forum guidelines to see how to properly post code .

Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

What Arduino board are you using? If it is a 5V board do you have the voltage divider on the Arduino TX (5V) to HC05 RX (3.3V)? Are you aware that the EN pin is not 5V tolerant.

That does not inspire confidence.

Here is a proven way to get a HC05 into AT mode that you may wish to try in order to see if your HC05 will talk to your Arduino. This has worked with all of my HC05 Bluetooth modules and for at least 3 members that tried it.

This instruction is for the HC05 module marked ZS-040 connected to an Arduino Uno, Nano or any mega328 based board. Connect the HC05 as shown in the Martyn Currey page linked in my prior post. HC05 TX to Arduino pin 2 and HC05 RX to Arduino pin 3 (through voltage divider).

To change the baud rate you must first put the HC05 into AT mode. Do that by connecting the EN pin to 3.3V, NOT 5V. Then power up the Arduino board and HC05 module. The LED on the module should alternate lit for about 3 seconds and off about 3 second if it enters AT mode.

Upload the following code to the Arduino board.

// To enable AT mode connect the EN pin of the HC05
// to 3.3V.  Caution, do not connect EN to 5V.

#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); // RX | TX

const long baudRate = 38400;
char c = ' ';
boolean NL = true;

void setup()
{
   Serial.begin(38400);
   Serial.print("Sketch:   ");   Serial.println(__FILE__);
   Serial.print("Uploaded: ");   Serial.println(__DATE__);
   Serial.println(" ");

   BTserial.begin(baudRate);
   Serial.print("BTserial started at "); 
   Serial.println(baudRate);
   //BTserial.print("BTserial started at "); 
   //BTserial.println(baudRate);
   Serial.println(" ");
}

void loop()
{
   // Read from the Bluetooth module and send to the Arduino Serial Monitor
   if (BTserial.available())
   {
      c = BTserial.read();
      Serial.write(c);
   }

   // Read from the Serial Monitor and send to the Bluetooth module
   if (Serial.available())
   {
      c = Serial.read();
      BTserial.write(c);

      // Echo the user input to the main window. The ">" character indicates the user entered text.
      if (NL)
      {
         Serial.print(">");
         NL = false;
      }
      Serial.write(c);
      if (c == 10)
      {
         NL = true;
      }
   }
}

In serial monitor (baud rate set to 38400) you should see something like (the file directory will be a bit different):

    Sketch: D:\bt_test_AT\bt_test_AT.ino
    Uploaded: May 19 2022

    BTserial started at 38400

Type "AT" (no quotes) and enter. You may see:

    AT
    ERROR:(0)

That is normal.

Type "AT" (no quotes) and enter again. Now you should see:

    AT
    OK

If that is what you see, the HC05 is in AT mode and ready to accept AT commands.

To set to baud 115200, enter "AT+UART=115200,0,0" (no quotes).

HC05 AT command list with examples.

More HC05 information by Martyn Currie.