Bluetooth Bee vs. RgbLed Library

Hi for all!

I have just received my Stalker and my BT Bee and this may be a stupid newbie question:

I’m trying to make the RGB Led library (http://www.insanegiantrobots.com/arduino/rgbled.html) work with the BT Bee using the DemoCode, but every time I use the setupBlueToothConnection() function the LED stops fading / changing colors and all I got is white light (full power RGB). So, this means that the PWM stops working. I’ve already tried with all PWM pin combination for the LED, even with A0-7. I’ve also tried with SoftwareSerial instead of NewSoftSerial with no luck…

I’m using a common anode RGB LED plugged on 5V and 3 PWM pins on the Stalker. Here is the code:

[code]#include <NewSoftSerial.h> //Software Serial Port
#include <RgbLed.h>

#define RxD 11
#define TxD 12

#define DEBUG_ENABLED 0

#define LED1_PIN_RED 10
#define LED1_PIN_GREEN 9
#define LED1_PIN_BLUE 6

#define DURATION_BLINK 2000
#define DURATION_DELAY 2000

NewSoftSerial blueToothSerial(RxD,TxD);

RgbLedCommonAnode led_rgb1(LED1_PIN_RED, LED1_PIN_GREEN, LED1_PIN_BLUE, true);

void setup()
{
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
setupBlueToothConnection();
}

void loop()
{
led_rgb1.setColor(random(0xFFFFFF));
delay(1000);

}

void setupBlueToothConnection()
{
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=1\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(int len = blueToothSerial.available())
{
a = blueToothSerial.read();

if('O' == a)
{
  b = blueToothSerial.read();
  if('K' == b)
  {
    break;
  }

}

}
}

while( (a = blueToothSerial.read()) != -1)
{
//Wait until all response chars are received
}
}

//Send the command to Bluetooth Bee
void sendBlueToothCommand(char command[])
{
blueToothSerial.print(command);
CheckOK();
}[/code]

I need this to work to start programing. I want to be able to change the LED color thru an Android phone.

Can anyone help me, please?

Try to use the following code in setup instead of setupBlueToothConnection();

blueToothSerial.print("\r\n");
blueToothSerial.print("+INQ=1");
blueToothSerial.print("\r\n");
delay(1000);//comment this if it’s unnecessary

Thank you, Steve! It worked!

I’ve already tried to use Serial instead of NewSoftSerial and SoftwareSerial and also worked. But I wish to know why did it worked without the software serial ports and why you put that into the code. What is the need of NewSoftwareSerial for BT Bee to work? With only Serial I could have any conflicts?

Two more question I have:

  1. Can I use other pins to the RX and TX instead of 11 and 12? 28 and 29 perhaps?

  2. Why do I have to remove the BT Bee from Stalker every time I want to upload a sketch?

I know C++ and others programing languages, but I’m missing a newbie-friendly documentation on how code and hardware work together on seeeduino and BT Bee.

Thank you again,

Mario

Hi Mario,
It should be both ok to use Hardware serial or software serial port. I used both of them because I ever wanted to get some debug info on the super terminal from the hardware serial port.

  1. It should be ok to use other pins for soft serial port. However there’s no 28 or 29 pins for Stalker. You can get more info about how to use the soft serial by searching on arduino.cc.
  2. Which version of Stalker are you using? For v1.0, the hardware Serial port is connected directly with Bluetooth Bee serial port, which will affect the downloading process. There’s no such problem with v2.0.

Regards,

Steve

Hi Steve!

Sorry for the delay!

I got all working now with RgbLed and Amarino for the BT connection with Android.

I think I’ve got one of the few last Stalkers v.1. What a shame. Had I waited a week, I’d buyed the new version. :unamused:

Now I’m placing a new order and don’t want to get it wrong. I need an advice: what kind of battery fits best with seeeduinos (JST 2 pin)? I need something rechargable and reliable. The batteries you sell are all 3V. Anything? - common 9V batteries are drained very quickly with the BT bee on…

Thank you again!