Hi,
I am trying to connect Arduino Uno through BT with my Mac. I have a BT shield (Seeed) and I am pairng BT with Mac as I have seen in many tutorials, and everything is going fine. But after I am pairing when I am trying to use BT port for communications I am having problems. I am not being able to upload the code (error: avrdude: stk500_recv(): programmer is not responding), or when I open serial monitor I can not see anything there, and there are things that need to be shown in it. I really need some help, I am struggling with this problem for to long.
And by the way this is the code that I am using.
#include <Encoder.h>
#include <SoftwareSerial.h>
#define RxD 5
#define TxD 4
SoftwareSerial blueToothSerial(RxD,TxD);
Encoder knob(2, 3);
long positionShaft = -999;
long newVal;
void setup()
{
Serial.begin(9600);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
setupBlueToothConnection();
}
void loop() {
newVal = knob.read()/11.3777778;
if (newVal != positionShaft ) {
if(newVal>=360 || newVal<=-360){
knob.write(0);
}
Serial.print(1,DEC);
Serial.println(newVal,DEC);
Serial.println();
positionShaft = newVal;
}
if (Serial.available()) {
Serial.read();
Serial.println("Reset both knobs to zero");
knob.write(0);
}
}
void setupBlueToothConnection()
{
blueToothSerial.begin(38400); // Set BluetoothBee BaudRate to default baud rate 38400
blueToothSerial.print("\r\n+STWMOD=0\r\n"); // set the bluetooth work in slave mode
blueToothSerial.print("\r\n+STNA=SeeedBTSlave\r\n"); // set the bluetooth name as "SeeedBTSlave"
blueToothSerial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
blueToothSerial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
delay(2000); // This delay is required.
blueToothSerial.print("\r\n+INQ=1\r\n"); // make the slave bluetooth inquirable
Serial.println("The slave bluetooth is inquirable!");
delay(2000); // This delay is required.
blueToothSerial.flush();
}