Hi everybody!
I want to build up a bluetooth communication between two arduinos(an Uno and a Mega) I use a HC-05 and HC-06. I connected them to each other by following the instructions of this link:
Now the two modules are connected to each other (At least the blinks say that).
I want to send anything by the Uno to the Mega, but if i send something and print it to the serial monitor i always get just the number: 128, or a character like this: €.
I think i have the problem in my code, because i bulid the circuit like in the above link.
Here is my code
-For the Uno, with HC-05, which is the master:
#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); // RX | TX
// Connect the HC-05 TX to Arduino pin 2 RX.
// Connect the HC-05 RX to Arduino pin 3 TX through a voltage divider.
char c = ' ';
void setup()
{
// start the serial communication with the host computer
Serial.begin(9600);
Serial.println("Arduino with HC-05 is ready");
// start communication with the HC-05 using 9600
BTserial.begin(9600);
Serial.println("BTserial started at 9600");
}
void loop()
{
BTserial.print('1');
delay(100);
Serial.println('1');
}
-for the Mega with HC-06, which is the slave:
char c = ' ';
void setup()
{
// start the serial communication with the host computer
Serial.begin(9600);
Serial.println("Arduino with HC-05 is ready");
// start communication with the HC-05 using 9600
Serial1.begin(9600);
Serial.println("BTserial started at 9600");
}
void loop()
{
if (Serial1.available())
{
c = Serial1.read();
Serial.println(c);
}
}
I hope you can help.
Thanks!