Apanhei muito com eessa plaquinhaa em!!! e sabe o que eh pior ? pra voce receber os dados dela, voce deve usar o putty e conetar na porta, as que aparece na ide do arduino, nao recebe os dados.. rs.. demorei dois dia pra descobri essa treta..
recomendo usar ela na porta RX e TX do arduino, e claro invertendo, a do tx da bluetooth no rx do arduino e tx do bluetooth no rx do arduino.. porta TX1 e RX0
Atraves do putty conecta na porta COM5, se o led do bluetooth ficar ligado sem piscar é porque ja ta conectado. antes disso pareie o windows com o linvor, e digite a senha 1234
led parou de piscar é pq ta conectado, digite no console do putty o valor !a" sem as aspas, ele vai receber o comando e ligar o led da porta 13, led onboard.
Use este codigo:
#include <SoftwareSerial.h>
/* DIO used to communicate with the Bluetooth module's TXD pin */
#define BT_SERIAL_TX_DIO 6
/* DIO used to communicate with the Bluetooth module's RXD pin */
#define BT_SERIAL_RX_DIO 5
/* Initialise the software serial port */
SoftwareSerial BluetoothSerial(BT_SERIAL_TX_DIO, BT_SERIAL_RX_DIO);
const int portaled = 13;
void setup()
{
Serial.begin(9600);
/* Set the baud rate for the software serial port */
BluetoothSerial.begin(9600);
pinMode(portaled, OUTPUT);
digitalWrite(portaled, LOW);
}
void loop()
{
if (BluetoothSerial.available())
Serial.write(BluetoothSerial.read());
/* If data is available from the hardware serial port then pass it on
to the Bluetooth module. */
if (Serial.available())
BluetoothSerial.write(Serial.read());
if (Serial.available()) {
int c = Serial.read();
if (c == 'a')
{
digitalWrite(portaled, HIGH);
Serial.println("ok ligado");
}
else if(c == 'b')
{
digitalWrite(portaled, LOW);
Serial.println("ok desligado");
}
}
delay(300); //make it readable
}