SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By hgchcw
#190490
I have installed the Bluetooth module cc2541 in UNO board. Here is the program. I have written an app to connect Arduino via cc2541. However, when I try to pair up cc2541 with my mobile, it can't and says that can't communicate with the Bluetooth module. What's wrong with my coding?

Many Thanks,
Raymond

#include <SoftwareSerial.h>
#include <Wire.h>//import necessary libraries: SoftwareSerial, Wire
SoftwareSerial I2CBT(6,9);//define PIN9 and PIN6 as RX and TX

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
I2CBT.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

}

void loop() {
byte cmmd[20];
int insize;
while(1){
if ((insize=(I2CBT.available()))>0)
{
Serial.print("input size = ");
Serial.println(insize);
for (int i=0; i<insize; i++) {
Serial.print(cmmd=char(I2CBT.read()));
Serial.println(" ");
}//if
} //for
} //while

}