Hey all, I'm trying to get my two Arduino Unos to communicate by sending a String from the Arduino connected to the HC05 unit and for the HC06 to receive it. The bluetooth modules are configured correctly, but with the code, all that is received is
X
X
X
X
18
ø€€€€ø€ø€€€€€€€ø€€
X
X
X
18
ø€€€€ø€ø€€€€€€€ø€€
over and over again. I completely understand why the 'X's are there, but I don't understand why the length is 18 and the input is garbage.
The SoftwareSerials communicate using the bluetooth and the Serial communicates to my computer.
My sending and receiving code is below:
Sending:
#include <SoftwareSerial.h>
SoftwareSerial ss(9,8); // RX, TX -> TX, RX
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
ss.begin(9600);
}
char inChar = ' ';
String inString = "";
void loop() {
// put your main code here, to run repeatedly:
String color = "S255000000S\n";
inString = "";
ss.print(color);
delay(1000);
Serial.print(color);
delay(1000);
while(ss.available()>0){
Serial.println("WORKING!");
inChar = ss.read();
inString += inChar;
}
if(inString.length() >= 2){
Serial.println(inString);
}
}
Receiving:
#include <SoftwareSerial.h>
SoftwareSerial ss(9,8);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
ss.begin(9600);
}
char inChar = ' ';
String inString = "";
int color[3] = {0,0,0};
void loop() {
// put your main code here, to run repeatedly:
inString = "";
while(ss.available()>0){
inChar = ss.read();
inString += inChar;
delay(4);
}
ss.println("X");
Serial.println("X");
if(inString.length() > 0){
Serial.println(inString.length());
Serial.println(inString);
}
delay(500);
}