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?