Bluetooth module only outputting 255

Playing around with the HC-05 bluetooth module and can't seem to get it working. I'm using the simple sketch from the arduino website Link.

int state = 0;
void setup() {
  Serial.begin(9600); // Default communication rate of the Bluetooth module
void loop() {
  if(Serial.available() > 0){ // Checks whether data is comming from the serial port
    state =; // Reads the data from the serial port

Connections: Arduino HC-05

TX > RX RX > TX 5V > 5V GND > GND

I use one of the apps on the playstore to connect to the module and send data. The only thing I receive is 255 (or 11111111 or ?). Sometimes I receive different data but it is very inconsistent. It is really starting to annoy me so I would like some help. Thanks in advance.

If code is from Arduino website, it should be kosher, but it [u]might[/u] be a little unstable without a little delay. Try

String readString;
char c;

void setup()
    pinMode(0, INPUT_PULLUP);// only needed for  JY-MCU v1.06?
    Serial.println("OK then, you first, say something.....");
    Serial.println("Go on, type something and hit Send,");
    Serial.println("or just hit the Enter key,"); 
    Serial.println("then I will repeat it!");

void loop() {
    while (Serial.available()) 
    c =;
    readString += c; 
  }// end while
  if (readString.length() >0) 
  } // end if