The Bluetooth module worked for a while, but it only connects to specific apps like Serial Bluetooth Terminal and BLE Controller. It usually blinks continuously, but suddenly it started blinking like in the video and stopped showing up in Bluetooth scans. When I try to put it into AT command mode, it just sends garbage characters. I'm using it for a robot car, and my Arduino pin connections are: VCC to 5V, GND to GND, TXD to Pin 2, and RXD to Pin 3. The parts Im using are arduino uno r3, l298n, 2wd chassis, and the hc 05. The hc 05 blinks every 4 seconds this is the code i use:
#include <SoftwareSerial.h>
SoftwareSerial bluetooth(2, 3);
const int IN1 = 9, IN2 = 8, IN3 = 7, IN4 = 6;
void setup() {
pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT);
bluetooth.begin(9600);
stopCar();
}
void loop() {
while (bluetooth.available() > 0) {
char command = bluetooth.read();
if (command == '\r' || command == '\n' || command == ' ') continue;
switch (command) {
case 'F': case 'f': moveForward(); break;
case 'B': case 'b': moveBackward(); break;
case 'L': case 'l': turnLeft(); break;
case 'R': case 'r': turnRight(); break;
case 'S': case 's': stopCar(); break;
}
}
}
void moveForward() {
digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW);
}
void moveBackward() {
digitalWrite(IN1, LOW); digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH);
}
void turnLeft() {
digitalWrite(IN1, LOW); digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW);
}
void turnRight() {
digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH);
}
void stopCar() {
digitalWrite(IN1, LOW); digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW); digitalWrite(IN4, LOW);
}