Hi, I am using my Arduino Mega 2560, and trying to program my RN-41 Bluetooth device, using the sample code provided on the bluetooth’s homepage. The code seems fairly straightforward, and is as follows:
#include <SoftwareSerial.h>
int bluetoothTx = 46; // TX-O pin of bluetooth mate, Arduino D2
int bluetoothRx = 45; // RX-I pin of bluetooth mate, Arduino D3
char data;
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup()
{
Serial.begin(9600); // Begin the serial monitor at 9600bps
delay(500);
bluetooth.begin(115200); // The Bluetooth Mate defaults to 115200bps
bluetooth.print("$"); // Print three times individually
bluetooth.print("$");
bluetooth.print("$"); // Enter command mode
delay(100); // Short delay, wait for the Mate to send back CMD
bluetooth.println("U,9600,N"); // Temporarily Change the baudrate to 9600, no parity
// 115200 can be too fast at times for NewSoftSerial to relay the data reliably
bluetooth.begin(9600); // Start bluetooth serial at 9600
Serial.print("<Arduino is ready>");
}
void loop()
{
if(bluetooth.available()) // If the bluetooth sent any characters
{
data = bluetooth.read();
// Send any characters the bluetooth prints to the serial monitor
Serial.print(data);
}
if(Serial.available()) // If stuff was typed in the serial monitor
{
data = Serial.read();
// Send any characters the Serial monitor prints to the bluetooth
bluetooth.print(data);
}
// and loop forever and ever!
}
My problem is, after opening up the Serial Monitor, and entering the $$$ command to enter into command mode, the tutorial mentions that the bluetooth should respond with CMD to confirm that I am in command mode. However, it does not respond, in fact, there is nothing printed in return from the bluetooth. If I am missing some simple step, please help. I’m going crazy!!!