I'm new to programming with the Arduino and am having trouble with communication over bluetooth.
I am able to send data from the computer across bluetooth to the Arduino but I am not receiving data from the board when I try to just send a typical message (byte or string). If I use an infinite while loop with only sending data (code below), I do receive correct data across the bluetooth on the computer. Also, both sets of code run as expected over the USB comm port.
I have the bluetooth module on port 0 and 1 and have the code set the baud to the default of the bluetooth module of 115.2k baud. The CTS and RTS of the bluetooth module are connected together. I have the computer set to 115.2k baud.
Does anyone have any suggestions on troubleshooting? Or has anyone successfully used this hardware together?
Currently, I do have the board's and the bluetooth's power coming through the Arduino's USB port. Would having the USB port connected cause this problem?
Hardware In Use:
Arduino Duemilanove
BlueSMiRF Gold - Bluetooth Modem - BlueSMiRF Gold (Old-School) - WRL-00582 - SparkFun Electronics
Software:
I've tried using Hyperterminal and TeraTerm
Arduino While Loop that works:
void loop(){
while(true){
Serial.print("H");
}
}
Code running on the Arduino that is not working:
int ledPin = 13;
int val = 0;
void setup(){
Serial.begin(115200);
delay(500);
}
void loop(){
while(Serial.available()>0){
val=Serial.read();
if(val=='H'){
digitalWrite(ledPin,HIGH);
Serial.print("High");
}
else if(val=='L'){
digitalWrite(ledPin,LOW);
Serial.print("Low");
}
else{
}
}
}