Communication problem between Bluetooth Uno and Max MSP

Hi there, I have done a fair amount of research but I can’t seem to find a solution to this, I hope you can help!

I have an Arduino Uno taking sensor readings, and I am trying to relay this information through a HC-06 bluetooth module through to Max MSP. My Mac is connecting to the HC-06 fine, and it is given as an option in Max’s list of serial ports. I’m using the ever popular “Arduino2Max_Nov2012” Max Patch and Arduino code. The readings are 0 for all analogue and digital pins.

I have adjusted the code to match the HC-06’s baud rate of 9600 in the Arduino code, and in the Max patch the serial object has been adjusted to “serial a 9600 8 1 0” instead of “serial a 115200 8 1 0.” Here is the Arduino code:

 int x = 0;                              // a place to hold pin values
int ledpin = 13;

void setup()
{
  Serial.begin(9600);               // 115200 is the default Arduino Bluetooth speed - changed to 9600 here
  digitalWrite(13,HIGH);              ///startup blink
  delay(600);
  digitalWrite(13,LOW);
  pinMode(13,INPUT);
}



void loop()
{ 

if (Serial.available() > 0){         // Check serial buffer for characters
        
    if (Serial.read() == 'r') {       // If an 'r' is received then read the pins
    
for (int pin= 0; pin<=5; pin++){      // Read and send analog pins 0-5
    x = analogRead(pin);
    sendValue (x);
    }



for (int pin= 2; pin<=13; pin++){     // Read and send digital pins 2-13
    x = digitalRead(pin);
    sendValue (x);
    }
  
    Serial.println();                 // Send a carriage returnt to mark end of pin data. 
    delay (5);                        // add a delay to prevent crashing/overloading of the serial port
  
  }

 }
}

void sendValue (int x){              // function to send the pin value followed by a "space". 
 Serial.print(x);
 Serial.write(32); 
}

I have used the same set-up (without the baud rate changes) many times successfully in the past, so I’m quite sure the problem lies in the bluetooth somewhere.
The HC-06 is RX-TX TX-RX’d to the Arduino, do I need to specify to the arduino to communicate on these pins, instead of through USB? This is what I think may be the issue.

I hope you can help me out! Thanks.

The HC-06 is RX-TX TX-RX'd to the Arduino, do I need to specify to the arduino to communicate on these pins, instead of through USB? This is what I think may be the issue.

On a UNO, "on Rx and TX" and "through USB" mean the same thing.

So are you saying that I don't need to let the Arduino know in any way, to communicate data through pins 0 and 1, rather than via the USB port? Maybe I am missing something in what you said

Maybe I am missing something in what you said

No, you aren't.

OK. Do you have any idea where the problem might be?

In case any one else stumbles across this with a similar problem: the problem was in the bluetooth module. I used the exact same methods/techniques with a different HC06 and it worked perfectly.

:D