I've got FastLED working beautifully on my project and am attempting to add bluetooth

I’ve got FastLED working beautifully on my project and am attempting to add bluetooth control but I seem to need some help. I’ve got the android LED controller app installed on my nexus 7, and my DFRobot V3 bluetooth chip powered up and paired with the nexus. The code is running on my Arduino Micro and the lights are on and running the initial mode I’ve selected. I’ve connected to my BT device in the app. However, when I try to change modes and press “engage” in the android app, nothing happens. :frowning:

I’ve connected TX → pin 2 and RX → pin 3 on my arduino micro. (also power and ground are hooked up)

I’ve tried all the various baud rates (uncommenting each line one at a time) and it doesn’t help. The default on my BT chip is 9600 baud.

I have updated the code as follows:

#include <SoftwareSerial.h>
#include <FastSPI_LED2.h>

#define VERSION_NUMBER 0.51

//—LED SETUP STUFF
#define LED_COUNT 28 //FOR TESTING w/ SIGN
#define LED_DT 9 //SERIAL DATA PIN
#define LED_CK 11 //SERIAL CLOCK PIN
#define DATA_PIN 9

int BOTTOM_INDEX = 0;
int TOP_INDEX = int(LED_COUNT/2);
int EVENODD = LED_COUNT%2;
struct CRGB leds[LED_COUNT];
int ledsX[LED_COUNT][3]; //-ARRAY FOR COPYING WHATS IN THE LED STRIP CURRENTLY (FOR CELL-AUTOMATA, MARCH, ETC)
int ledMode = 3; //-START IN RAINBOW LOOP
//int ledMode = 888; //-START IN DEMO MODE
//int ledMode = 888; //-MODE TESTING

int thisdelay = 20; //-FX LOOPS DELAY VAR
int thisstep = 10; //-FX LOOPS DELAY VAR
int thishue = 0; //-FX LOOPS DELAY VAR
int thissat = 255; //-FX LOOPS DELAY VAR
int max_bright = 64; //-SET MAX BRIGHTNESS TO 1/4

int thisindex = 0; //-SET SINGLE LED VAR
int thisRED = 0;
int thisGRN = 0;
int thisBLU = 0;

//—SERIAL/SOFTWARE SERIAL SETUP STUFF
#define SERIAL_BAUDRATE 9600
//#define SERIAL_BAUDRATE 57600
//#define SERIAL_BAUDRATE 115200
#define SERIAL_TIMEOUT 5

#define SOFT_RX_PIN 2 // BTCHIP-TX → NANO-SOFT-RX (2)
#define SOFT_TX_PIN 3 // BTCHIP-RX → NANO-SOFT-TX (3)

SoftwareSerial btSerial(SOFT_RX_PIN, SOFT_TX_PIN);
int btBOOL = 1; //-ACTIVATE BLUETOOTH OR NOT
byte inbyte; //-SERIAL INPUT BYTE
int thisarg; //-SERIAL INPUT ARG

Here’s a photo of me wearing my project. Yes! It’s a light-up, swimmable mermaid tail. I am almost ready to do some photo shoots but I really need to be able to change modes without completely de-mermaid-ing.

Any and all advice and help is greatly appreciated!!! (I’m having no end of trouble with bluetooth on this project and am just about ready to rip all my fins out)

Grab one of the SoftSerial examples and modify it to output what you comes in the soft serial port to the real serial port. load this sketch. then watch the serial monitor - does anything come out? Try Swap RX and TX and try again. You may have RX/TX swapped or 3.3V to 5V level translation issues. Tell us more about the hardware you’re having the issue on. Have you tried swapping RX and TX at all?

I have tried swapping RX and TX. I also just tried running SoftwareSerialExample and could not get the serial monitor to show anything but the occasional burst of gobbledygook.

I was able to enter command mode with this BT chip and change its name and verify that it’s set to 9600 baud. And it does connect and pair beautifully with things.

Here is the test I just ran. I got a “goodnight moon” on the USB serial port but nothing on the BT serial port.

/*
Software serial multple serial test

Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.

The circuit:

  • RX is digital pin 10 (connect to TX of other device)
  • TX is digital pin 11 (connect to RX of other device)

Note:
Not all pins on the Mega and Mega 2560 support change interrupts,
so only the following can be used for RX:
10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

Not all pins on the Leonardo support change interrupts,
so only the following can be used for RX:
8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

created back in the mists of time
modified 25 May 2012
by Tom Igoe
based on Mikal Hart’s example

This example code is in the public domain.

*/
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX

void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}

Serial.println(“Goodnight moon!”);

// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
mySerial.println(“Hello, world?”);
}

void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}

OK. I got it to print Hello World, by switching to pins 10 & 11. Once the BT was responding I didn’t touch ANYTHING and went back to the Funkboxing sketch, switched RX and TX to 10 and 11, and tried again. Still no response. I also tried sending commands through the serial monitor (cutting out the nexus part of the equation) and still, no response.

aaaaand suddenly it’s working. WHY. Argh. but. It’s working. I think perhaps I will just never turn it off ever.

I’ve been able to get the NRF8001 BTLE module from adafruit working recently - and have had that play nicely w/FastLED. I haven’t gotten a hold of or tried to get this particular bluetooth module working. If you decide to go that route, I can give you the basic code that I am using for that as a basis for future BTLE type stuff.

With this module, I’d be happy to try to get my hands on one of these and take a swing at getting it up and running (or, if you’re in the bay area and can swing one by to me, that’d probably work as well - I don’t think i’d need it for long, but this is one of those things that I generally debug better in hand, personally) - is it this one - http://www.dfrobot.com/index.php?route=product/product&filter_name=v3%20bluetooth&product_id=360#.Uz37iNywO0w ?

Actually, before recommending the BTLE route - which nexus 7 do you have? If it’s the 2012 one that won’t support BTLE, if it’s the 2013 one, it will.

(this is what I get for not hitting refresh before finally posting a comment!) - glad to hear that it’s working - and that “It’s suddenly working and I don’t know why” thing is something that I wish I could say i’ve never experienced, but then i’d be lying.

A lot.

I have the 2013 Nexus, I just got it. It works for a bit but I’m finding the arduino app is kind of buggy. Wondering if I have the most recent version, or if there’s a newer version? Also, is the source code available somewhere? Thanks!!

Which app are you using? So far i’ve been using iOS for my bluetooth testing - I haven’t tracked down an android app, but figured I could throw something together in a pinch if I couldn’t.

The one linked from here: http://funkboxing.com/wordpress/?p=2154

(and there is my answer to the question of “is the code available” also. thanks, lazyweb)

Try using AT commands to raise the baud on your bt chip to 57600. The android app actually sends commands too fast on faster android hardware and at 9600 the duino might be overflowing. I’ll work on updating the app to fix that soon. Also- can I post a link to your project on funkboxing? Very cool project.

Ah, nifty - something else to play with - I was just trying the nRF UART android app w/the BTLE module and it works nicely.

So many things to play with!

I’m really hoping to be able to step away from the library for a few hours over the next few days, though. I need to bring out the core of Locus and see what the state of that thing is, and start working on some designs for the wall for it. I also have a couple of other “around the house” led projects I really want to put some time into.

Share photos/videos of the tail in action when you get them! I’m really curious to see how the leds look/play under water.

And just because it needs saying, HOLY MARINE LIFE that’s a fantastic and just amazingly beautiful creation! And swimmable! Wow!

This is fantastic. I was also looking into the same funkboxing project for BT comms.

Thanks guys! Once I get a blog post out I will announce it “for real” and then would love all the link love and sharing I can get. Water testing it this week. Here is hoping I do not electrocute myself. :slight_smile: