Closed qiugai closed 1 year ago
Might need to switch bluetooth modules as a last resort. HC-06 is only a slave driver, and AT mode is not easily configured unlike the HC-05, HM-10, etc.
Potentially can tap into this LED header and use it to monitor the connection (depends on the age of our model).
Potentially can tap into this LED header and use it to monitor the connection (depends on the age of our model).
Should be able to work, plastic sleeve needs to be removed to access pin 24 -- unless the STATE pin in our model is connected directly to LED. Can
Below code (sourced from http://www.martyncurrey.com/hc-05-fs-040-state-pin/#:~:text=The%20STATE%20pin%20is%20LOW,value%20of%20the%20STATE%20pin.), shows an example of using the HC-05 bluetooth modules state pin. This is a possible solution to detect connection/disconnection.
// BTconnected will = false when not connected and true when connected
boolean BTconnected = false;
// connect the STATE pin to Arduino pin D4
const byte BTpin = 4;
void setup()
{
// set the BTpin for input
pinMode(BTpin, INPUT);
// start serial communication with the serial monitor on the host computer
Serial.begin(9600);
Serial.println("Arduino is ready");
Serial.println("Connect the HC-05 to an Android device to continue");
// wait until the HC-05 has made a connection
while (!BTconnected)
{
if ( digitalRead(BTpin)==HIGH) { BTconnected = true;};
}
Serial.println("HC-05 is now connected");
Serial.println("");
// Start serial communication with the bluetooth module
// HC-05 default serial speed for communication mode is 9600 but can be different
BTserial.begin(9600);
}
Robot stops immediately on disconnect due to added code and hc-05 module switch
Expected Behavior
No matter the joystick's position, the robot will stop driving when bluetooth disconnects.
Actual Behavior
If joystick is not in the original position at time of disconnection, robot will drive continuously until it collides with an obstacle.
Steps to reproduce
To replicate this behavior, connect to the car's bluetooth HC-06 module using the bluetooth menu in the flutter app. Drive until disconnection and continue holding the joystick. Alternatively, have someone pick up the car and press the reset button on the bluetooth while the joystick is being held.
Attempted Solution
Tick system reimplemented - Caused car motors to randomly stop.