Hi there.
I’m quite new to the arduino programming. I am using a Seeeduino Stalker v2.2 with a Bluetooth Bee module placed directly on the bee series socket on the stalker. the board is connected to pc via uartsbee:
I tried that wiki sample code:
[code]
#include <SoftwareSerial.h> //Software Serial Port
#define RxD 11
#define TxD 12
#define DEBUG_ENABLED 1
SoftwareSerial blueToothSerial(RxD,TxD);
void setup()
{
Serial.begin(9600);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
setupBlueToothConnection();
}
void loop()
{
//Typical Bluetoth command - response simulation:
//Type ‘a’ from PC Bluetooth Serial Terminal
//See Bluetooth Bee - Wiki for instructions
if(blueToothSerial.read() == ‘a’)
{
blueToothSerial.println(“You are connected”);
//You can write you BT communication logic here
}
}
void setupBlueToothConnection()
{
Serial.print(“Setting up bluetooth bee…”);
blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
delay(1000);
sendBlueToothCommand("\r\n+STWMOD=0\r\n");
sendBlueToothCommand("\r\n+STNA=SeeeduinoBluetooth\r\n");
sendBlueToothCommand("\r\n+STAUTO=0\r\n");
sendBlueToothCommand("\r\n+STOAUT=1\r\n");
sendBlueToothCommand("\r\n +STPIN=0000\r\n");
delay(2000); // This delay is required.
sendBlueToothCommand("\r\n+INQ=1\r\n");
delay(2000); // This delay is required.
}
//Checks if the response “OK” is received
void CheckOK()
{
char a,b;
while(1)
{
if(blueToothSerial.available())
{
Serial.print(“Available…”);
a = blueToothSerial.read();
Serial.println(a);
if(‘O’ == a)
{
// Wait for next character K. available() is required in some cases, as K is not immediately available.
while(blueToothSerial.available())
{
b = blueToothSerial.read();
Serial.println(b);
break;
}
if(‘K’ == b)
{
break;
}
}
}
}
Serial.print(“Ok”);
while( (a = blueToothSerial.read()) != -1)
{
//Wait until all other response chars are received
}
}
void sendBlueToothCommand(char command[])
{
Serial.print(command);
blueToothSerial.print(command);
CheckOK();
}[/code]
maybe you can guess that it did not work. Output:
(resettet stalker one time…)
I’m not quite sure - i guess i might use the wrong pins (although i am confused why i pass that .available() then?). Can somebody tell me whether this is the problem (and how to solve it) - or what else might be the problem…
Update 25/10/12 10:29:
Studying the schematics I think that I have to use PD0 (Pin1) for RXD and PD1 (Pin2) for TXD in this scenario (right?). Updated my code to the pins 1 and 2.
now im getting this output…:
After that it infinitely outputs “Available…x”
what am i doing wrong…? Pls help.
Thanks in advance,
apbs