HC05 bluetooth module crash

I used AT commands to change the baud rate of the hc05 module and now it always in the command mode no matter what and it does not respond at all. What should i do (Bluetooth module is zs-040)

Please post schematics and code.

#include <SoftwareSerial.h>
SoftwareSerial BTSerial(11, 12); // RX | TX

void setup()
{
  pinMode(7,OUTPUT);// this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
  pinMode(9, OUTPUT);
  pinMode(10,OUTPUT);  
  digitalWrite(9, HIGH);
  digitalWrite(10,LOW);
  digitalWrite(7,HIGH);
  Serial.begin(9600);
  Serial.println("Enter AT commands:");
  BTSerial.begin(38400);  // HC-05 default speed in AT command more
}

void loop()
{

  // 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());
}

before i change the bund rate, AT commands did work and I did some changes. but after I change the bund rate to 38400 the Bluetooth module stopped working it not respond to neither 9600 or 38400. Also now it always stuck in the command mode.

Module Pin34 should be tied to the enable pin through the button switch.

I'd remove the pin 34 connection to pin7 which you are always writing HIGH and will keep the module in AT mode.

digitalWrite(7,HIGH);

Power the HC05 from the 5 volt pin, not a digital pin.

I removed it but still it didn’t work

I tried that but still didn’t work

minlish

The Arduino Mega itself has serial interfaces. Check that.

What is the blink pattern you see on the HC05.
Are you sending the AT command terminators '\r' , '\n' when you try and reset or change the settings?

If you think you are in AT mode, have you tried to send AT+ORGL for a factory reset.

As already said, try and use hardware serial to communicate in AT mode. Software serial can be flaky at 38400 baud. AltSoftSerial is better if you must use software serial.