Arduino Car

Give me a code to automatically stop motors when Bluetooth is disconnected/out of range.
I have a arduino car in which I used hc-05, l298n motor driver and Arduino UNO R3.

if (bluetoothDisconnected ()) {
  stopMotors ();


Give me a code

We don't give you code.

We help with problems in your code.

If your Bluetooth device sends messages at regular intervals (say 5 per second) the Arduino can measure the time between messages and if it is too long it can stop the motor.