RN-42 and Arduino connection

Hello,
Need help. I have the following setup Arduino UNO R3, Bluetooth RN-42, Android tablet with "BlueTerm" application. I soldered everything and the tablet is connecting to the RN-42 just fine. I can also short the RX and TX on the RN-42 and see the character echo on the tablet.
On the connection to the Arduino - I'm able to send text from the Arduino to the tablet terminal.
The thing that is not working is the connection between the output of the RN-42 and the input to the Arduino.
When I load the program below, the led only turns on for 2 seconds, meaning that the Serial.available() is working only when I connect the TX from the RN-42 to the RX of the Arduino - and then it is not available for the next time the loop occurs - any ideas??

int ledPin=8;
void setup()
{
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
}

void loop()
{

if (Serial.available() >0)
{
char cmd = Serial.read();
Serial.print(cmd);
digitalWrite(ledPin, HIGH);

if (cmd=='1')
{
digitalWrite(ledPin, HIGH);
Serial.print("HIGH");
}
else if (cmd == '0')
{
digitalWrite(ledPin, LOW);
Serial.print("LOW");
}
} else {digitalWrite(ledPin, LOW);}

delay(2000);
}

Sorry for asking the obvious, but are you continuing to send characters from the Android? Serial.available() will return false once you've emptied the receive buffer.

FWIW, I've gotten the RN-42 to work in a similar situation with an Arduino-compatible board, so I'm confident you'll get this solved.

Jim

Thanks for the reply Jim.

Yes, of course - I'm trying to send the characters from the Android like a crazy man, but the Arduino doesn't respond to any input, even though I know for sure that the TX from the Arduino is active and is sending the characters that I type.

I'm so lost on this.

One thing that I did read is that somewhere I should define the port on the Arduino for the connection with the bluetooth? I'm using Linux (11.10) and the Arduino is defined on.../ACM0 but other than that I don't know where to define a specific port for the Arduino to talk to the bluetooth.

Thanks again for your help.

Sorry - I mean the TX from the RN-42.

boom3761:
One thing that I did read is that somewhere I should define the port on the Arduino for the connection with the bluetooth? I'm using Linux (11.10) and the Arduino is defined on.../ACM0 but other than that I don't know where to define a specific port for the Arduino to talk to the bluetooth.

I'm not following this. The Linux box shouldn't be connected to the USB port on your Uno while you are using the RN 42. So (unless I am missing something) the port setup on your Linux box would be irrelevant.

My suggestion would be to use a stripped-down sketch that does nothing more than flash the LED briefly every time a character is read from Serial. You might also want to try to establish communication with the Uno/R42 through a BT connection to your Linux box to see if the problem maybe lies with the Android app.

Jim

Thanks Jim. I think this is was a progress for me - When I tested this, I always had the Arduino and the Linux connected since I used the USB as the only source of power. Didn't that the serial USB connection had to be disconnected in order for this sketch to work.

I tried the sketch again with a 9V connection (without the USB) and although it still doesn't work, I was able to see "LOW" on the Android app one time - which is a first since I was never able to have a print from within the "if cmd".

As for the Android app, I did try 2 separate apps in the process and also when I short the TX and RX on the RN42 - I get the echo on the terminal on the Android - I don't know if it means that the problem is somewhere else though.

Thanks for the first advice though I didn't realize the USB to Linux had to be disconnected. I wish I was a little bit closer to get this setup to work though...

Problem was resolved just by replacing the RN42 module with a new one