I'm trying to make bluetooth controller for my new arduino based robot (HC-05 on robot & HC-06 on controller). But I have big issue with bluetooth serial... Both bt modules blinks leds like it should be succesfully connected with each other, but when i try to send data to other arduino, it's not working... I am not using SoftwareSerial, but I connected both bt modules' tx&rx directly to arduino tx&rx pins. At one point the robot arduino was getting "-1" data.
Robot code:
#include <Servo.h>
//Servo Configurations
Servo Servo1; //Turn
Servo Servo2; //Head move forward/backward
Servo Servo3; //Head move sideways
int pos1 = 90;
int pos2 = 100;
int pos3 = 100;
//L298N Configuration
int IN1 = 2;
int IN2 = 3;
int IN3 = 4;
int IN4 = 5;
int ENA = 6;
int ENB = 10;
int RUN = 1;
void setup()
{
//Data rate for the SoftwareSerial port
Serial.begin(9600);
Serial.println("Drive-system is ready.");
//Motor-pins
pinMode(ENA, OUTPUT);
pinMode(ENB, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
//Define the servo digital pins
Servo1.attach (9);
Servo2.attach (8);
Servo3.attach (7);
Servo1.write(pos1);
Servo2.write(pos2);
Servo3.write(pos3);
}
void loop()
{
Serial.write('1');
delay(500);
}
Controller code:
//Left Joystick
const int L_Y_pin = A1;
const int L_X_pin = A0;
int L_Y_value = 0;
int L_X_value = 0;
//Right Joystick
const int R_Y_pin = A2;
const int R_X_pin = A3;
int R_Y_value = 0;
int R_X_value = 0;
//Left button
const int L_Button_pin = 13;
int L_Button_state = 0;
//Right button
const int R_Button_pin = A7;
int R_Button_state = 0;
void setup()
{
Serial.begin(9600);
Serial.println("Controller is ready.");
pinMode(13, INPUT);
pinMode(A7, INPUT);
pinMode(A3, INPUT);
pinMode(A2, INPUT);
pinMode(A1, INPUT);
pinMode(A0, INPUT);
}
void loop()
{
Serial.write('2');
delay(500);
}