Arduino Micro connection with Leonardo with HC-05 Bluetooth module
help, i'm desperate!
i can not talk arduini!
the bluetooth modules flash @ 9600 baud.
even if load of bt probe programs (tx , rx of micro leonardo) modules not communicate serial!
i tried use serial1 in both arduino modules
here test programs:
// ****************tx su micro
const int tastatore = 6;
const int ledpin = 13;
void setup() {
serial.begin(19200) ;
serial1.begin(9600) ;
while (!serial1);
pinmode(tastatore, input);
pinmode(ledpin, output);
}
void loop() {
if (digitalread(tastatore)){
digitalwrite(ledpin, low);
serial1.print("of");
serial1.print("/");
}
else if (!digitalread(tastatore)) {
digitalwrite(ledpin, high);
serial1.print("of");
serial1.print("/");
}
delay(4);
}
//************rx su leonardo
/
int led = 13;
char stringa_ricevuta[3];
byte indice_rx = 0;
byte inbyte;
void setup() {
serial.begin(19200) ;
serial1.begin(9600) ;
pinmode(led, output);
while (!serial1);
}
void loop()
{
if (serial1.available())
{
inbyte =serial1.read();
if ((inbyte != 47) && (indice_rx < 2)) //ricevi il dato fino / all'invio e max 5 byte
{
stringa_ricevuta[indice_rx++] = inbyte;
}
else
{
if (strcmp(stringa_ricevuta, "of") == 0)digitalwrite(led, low);
else if (strcmp(stringa_ricevuta, "on") == 0)digitalwrite(led, high);
stringa_ricevuta[indice_rx] = 0;
indice_rx = 0;
}
}
serial.print(inbyte);
}
i can not talk arduini!
the bluetooth modules flash @ 9600 baud.
even if load of bt probe programs (tx , rx of micro leonardo) modules not communicate serial!
i tried use serial1 in both arduino modules
here test programs:
// ****************tx su micro
const int tastatore = 6;
const int ledpin = 13;
void setup() {
serial.begin(19200) ;
serial1.begin(9600) ;
while (!serial1);
pinmode(tastatore, input);
pinmode(ledpin, output);
}
void loop() {
if (digitalread(tastatore)){
digitalwrite(ledpin, low);
serial1.print("of");
serial1.print("/");
}
else if (!digitalread(tastatore)) {
digitalwrite(ledpin, high);
serial1.print("of");
serial1.print("/");
}
delay(4);
}
//************rx su leonardo
/
int led = 13;
char stringa_ricevuta[3];
byte indice_rx = 0;
byte inbyte;
void setup() {
serial.begin(19200) ;
serial1.begin(9600) ;
pinmode(led, output);
while (!serial1);
}
void loop()
{
if (serial1.available())
{
inbyte =serial1.read();
if ((inbyte != 47) && (indice_rx < 2)) //ricevi il dato fino / all'invio e max 5 byte
{
stringa_ricevuta[indice_rx++] = inbyte;
}
else
{
if (strcmp(stringa_ricevuta, "of") == 0)digitalwrite(led, low);
else if (strcmp(stringa_ricevuta, "on") == 0)digitalwrite(led, high);
stringa_ricevuta[indice_rx] = 0;
indice_rx = 0;
}
}
serial.print(inbyte);
}
code: [select]
void loop() {
if (digitalread(tastatore)){
digitalwrite(ledpin, low);
serial1.print("of");
serial1.print("/");
}
else if (!digitalread(tastatore)) {
digitalwrite(ledpin, high);
serial1.print("of");
serial1.print("/");
}
delay(4);
}
does led stay off? why send "of"? shouldn't 1 of these send "on"?
Arduino Forum > Using Arduino > Programming Questions > Arduino Micro connection with Leonardo with HC-05 Bluetooth module
arduino
Comments
Post a Comment