Bluetooth Bee-Standalone

Save that extra Arduino you have lying around for another project, this two-for-one device has the Arduino built-in. Bluetooth Bee with Arduino is an enhanced version of the Bluetooth Bee. We added an onboard ATMEGA168 to it to make it a full-featured Arduino while maintaining the same footprint and instruction set as the Bluetooth Bee. Plus, it still allows you to stack it on XBee Carrier, XBee® Shield, and UartSBee for expansion or reprogramming.

/*BluetoothBee Demo Code - Flowcontrol Based Implementation2010,2011 Copyright (c) Seeed Technology Inc. All right reserved.Author: Visweswara R Modify:JoinjThis demo code is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAFor more details about the product please check http://www.seeedstudio.com/depot/*//* Upload this sketch to Seeeduino and press reset*/#include<NewSoftSerial.h> //Software Serial Port#define RxD 2#define TxD 3#define DEBUG_ENABLED 1NewSoftSerialblueToothSerial(RxD,TxD);voidsetup(){pinMode(RxD,INPUT);pinMode(TxD,OUTPUT);pinMode(5,OUTPUT);setupBlueToothConnection();}voidloop(){unsignedcharcontrol;unsignedchartemp;while(temp!='4'){temp=blueToothSerial.read();}Serial.println("You are connected");blueToothSerial.print("You are connected");//You can write you BT communication logic herewhile(1){temp=blueToothSerial.read();switch(temp){case'O':{while(temp!='N'){temp=blueToothSerial.read();}digitalWrite(5,HIGH);break;}case'S':{while(temp!='H'){temp=blueToothSerial.read();}digitalWrite(5,LOW);break;}default:break;}}}voidsetupBlueToothConnection(){blueToothSerial.begin(38400);//Set BluetoothBee BaudRate to default baud rate 38400delay(1000);sendBlueToothCommand("\r\n+STWMOD=0\r\n");sendBlueToothCommand("\r\n+STNA=SeeedBluetooth-st\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 receivedvoidCheckOK(){chara,b;while(1){if(blueToothSerial.available()){a=blueToothSerial.read();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();break;}if('K'==b){break;}}}}while((a=blueToothSerial.read())!=-1){//Wait until all other response chars are received}}voidsendBlueToothCommand(charcommand[]){blueToothSerial.print(command);CheckOK();}

Step 3

Connect the XBee carrier to computer with USB-cable and uploading the program to ATMEGA168 on the Bluetooth Bee-Standalone.

Step 4

Remove the USB-cable form XBee carrier and connect the 3.7-Voltage battery to XBee carrier like this.

Step 5

Use another Bluetooth Bee connect to the Bluetooth Bee-Standalone.How to connect? You can refer to Bluetooth Bee.When you are connected,you can control the LED by another Bluetooth Bee.The LED will work when you send "ON" to Bluetooth Bee-Standalone and it will be off when you send "SH"(short for SHUT).