Greetings! I am trying to simply send data to an Arduino Micro using and HC-06 bluetooth card. From the code below you'll see I have an LED on pin 7 which I'm trying to turn off as an indication that data has been received.
All of my send messages seem to work just fine ("Hello!", "You there?") however anything I send doesn't seem to get through. If I turn on the inData and printing statement, all I get are a bunch of -1 lines in my terminal (using Qwerty Bluetooth Terminal on my android phone to communicate with it).
Not sure if this is some kind of timing issue? If I change the baud rate to something other than 9600 the send messages come thru garbled.
Note: I included the FastLED library to leverage the "Every x seconds" functionality. Sort of ping to make sure I haven't dropped connection.
#include <SoftwareSerial.h>
#include <FastLED.h>
SoftwareSerial BT(6,5);
//int inData;
void setup() {
// put your setup code here, to run once:
BT.begin(9600);
BT.println("Hello!");
pinMode(7, OUTPUT);
delay(2000);
}
void loop() {
// put your main code here, to run repeatedly:
// inData = BT.read();
// BT.println(inData);
if (BT.available()) {
delay(10);
fromPC = (char)BT.read();
digitalWrite(7,LOW);
BT.println("received BT data");
} else {
digitalWrite(7,HIGH);
}
delay(100);
EVERY_N_MILLIS(20000) BT.println("You there?");
}
Changed to below so that the write is happening at a different time than the read. The serial monitor is just showing a bunch of -1's still. What's interesting to me is that in the previous code the LED wouldn't even go off. Seems like either the chip is expecting some kind of different data to be sent to it, OR maybe there a setting I missed in my phone bluetooth terminal to work right?
the Arduino Micro uses 5V logic so you require a potential divider on the Micro Tx to HC-06 Rx (similar to mega in post #4) software-serial documentation states Not all pins on the Leonardo and Micro boards support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
so you need to modify