Hi All,
I am trying to use Leonardo and trying to get the HC05 module communicate.
The connections which I have done is:
HC05 TX -> Leonardo RX
HC05 RX -> Leonardo TX
Both the Arduino and HC05 have been connected to common ground and 5V is supplied to HC05.
However I dont see anything in the COM window
Here is the Code below:
String inputString = "";
bool stringComplete = false;
int scoreLeft = 0;
int scoreRight= 0;
int timerMin = 0;
int timerSec = 0;
void setup() {
delay(500);
Serial.begin(9600);
Serial1.begin(9600);
while(!Serial) {
Serial1.begin(9600);
Serial.println("STARTING NOW");
}
strip.begin();
strip.setBrightness(50);
strip.clear();
strip.show();
inputString.reserve(200);
}
void loop() {
if (stringComplete) {
Serial1.println(inputString);
if(inputString.length()!=4){
inputString = "";
stringComplete = false;
Serial1.println("InCorrect LENGTH String Received!");
}
char cmd = inputString[0];
char param = inputString[1]-'0';
inputString = "";
stringComplete = false;
switch(cmd){
case 'L':
scoreLeft = scoreLeft+param;
Serial1.print("Score LEFT = ");
Serial1.println(scoreLeft );
showScore(scoreLeft,1);
break;
case 'l':
scoreLeft = scoreLeft-param;
Serial.print("Score LEFT = ");
Serial.println(scoreLeft );
showScore(scoreLeft,1);
break;
case 'R':
scoreRight= scoreRight+param;
Serial1.print("Score RIGHT = ");
Serial1.println(scoreRight);
showScore(scoreRight,2);
break;
case 'r':
scoreRight= scoreRight-param;
Serial1.print("Score RIGHT = ");
Serial1.println(scoreRight);
showScore(scoreRight,2);
break;
default:
Serial1.println("COMMAND NOT RECOGNIZED YET");
break;
}
}
}
void serialEvent() {
while (Serial1.available()) {
// get the new byte:
char inChar = (char)Serial1.read();
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag so the main loop can
// do something about it:
if (inChar == '\n') {
stringComplete = true;
}
}
}
It would be great, if someone could help me solve the issue with communication. I have used the Serial Blue Tooth Terminal (Android APP) but there seems to be no message coming in COM window apart from the first one Serial.println("STARTING NOW");