Well I want to communicate 2 Arduinos via Bluetooth. I have my HC-05 and a ZS-040 version of the HC-05. I managed to enter to AT mode and pair them, the HC-05 as master and the ZS-040 as slave. I uploaded this to the Arduino with the master:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2,3);
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
mySerial.println("Conectado");
}
void loop()
{
mySerial.write('a');
Serial.write(mySerial.read());
delay(2000);
mySerial.write('1');
Serial.write(mySerial.read());
delay(1000);
}
and this to the slave:
SoftwareSerial mySerial(2,3);
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
pinMode(11,OUTPUT);
digitalWrite(11,LOW);
}
void loop()
{
char c=mySerial.read();
if(c=='1') digitalWrite(11,HIGH);
if(c=='a') digitalWrite(11,LOW);
}
I want to send 1 and a and turn on and off a LED light. It does not work.
I included the line Serial.write(mySerial.read()); so I can read in the Arduino software if my HC-05 is sending the 1 and the a but when I put the serial monitor it just reads "ÿ" over and over....
Any advices? or ideas?