Hey All,
I am having some trouble with my two HC-05 Bluetooth modules. They don't seem to be connecting.
The master device is configured as follows: UART = 38400,0,0; ROLE = 1; CMODE = 0; BIND = the correct address of the slave device (I have checked this multiple times);
The slave device: UART = 38400,0,0; ROLE = 0; CMODE = 1;
Here is the code for the master device;
void setup() {
// put your setup code here, to run once:
Serial.begin(38400);
}
void loop() {
// put your main code here, to run repeatedly:
if (analogRead(A0) > 1000){
Serial.write('1');
}
if (analogRead(A0) < 100){
Serial.write('2');
}
if (analogRead(A1) > 1000){
Serial.write('3');
}
if (analogRead(A1) < 100){
Serial.write('4');
}
}
And here is the code for the slave;
void setup () {
Serial.begin(38400);
pinMode(13, OUTPUT); // built in led
}
void loop() {
if (Serial.available()){
if (Serial.read() == '1'){
digitalWrite(13, HIGH);
}
else { digitalWrite(13, LOW); }
}
}
I don't believe that the code is the problem; the Bluetooth modules don't even connect.
One possible problem could be that I am powering both with one computer, and I have a hunch this may be interfering with the serial communication.
Thanks in advance,
D