Hi,
I bought a few of these Bluefruit LE UART Friend to make into a glowing bluetooth items and im having some trouble with the color picker feature i have following the learning guide https://learn.adafruit.com/introducing- ... art-friend and still have had no luck in finding the code to make this all work.
Thanks for all the help.
Steven
Bluefruit LE UART Friend PID :2479
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Bluefruit LE UART Friend PID :2479
Post a photo of your hardware and connections and we'll take a look. 800x600 images usually work best.
- stevenrice
- Posts: 34
- Joined: Sat Mar 29, 2014 3:11 am
Re: Bluefruit LE UART Friend PID :2479
Please let know if you can't see the image I'm uploading it from my phone
- Franklin97355
- Posts: 23910
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Bluefruit LE UART Friend PID :2479
Which color picker feature is that? Do you have the jumpers soldered to the module? That is necessary for a good connection.im having some trouble with the color picker feature
- stevenrice
- Posts: 34
- Joined: Sat Mar 29, 2014 3:11 am
Re: Bluefruit LE UART Friend PID :2479
I haven't solder the pins on I don't know which code to upload to the arduino board I am using the color picker under the controller function I uploaded the at command code and can communicate over Bluetooth to serial on the PC and back and forth
- adafruitguy
- Posts: 206
- Joined: Sat Jun 07, 2014 7:52 am
Re: Bluefruit LE UART Friend PID :2479
I'd love to see sample Arduino code that utilizes the color picker controller module built into the Bluefruit LE app too.
- stevenrice
- Posts: 34
- Joined: Sat Mar 29, 2014 3:11 am
Re: Bluefruit LE UART Friend PID :2479
Ok so I got the Bluefruit to communicate over serial to control a strip of neopixels.
This is how I wired it
Pin :
mod - n/u
cts - ground
txo - digital pin 0 (rx) on arduino
rx1 - digital pin 1 (tx) on arduino
Vin - 5v
rts - n/u
gnd -ground
dfu - n/u
The code was created by my friend
upload the code to arduino and connect to the module via uart through the le connect app. And under type in the following values depending on the function desired
Functions
//solid---
s,r,g,b
//pulse---
p,r,g,b,delay(ms)
//rainbow----
r,speed(ms)
//twinkle----
t,r,g,b,(number to light),delay(ms)
//color fill----
c,r,g,b,(time to fill strip)
Code
#include <Adafruit_NeoPixel.h>
#define STRIP_PIN A3
Adafruit_NeoPixel strip = Adafruit_NeoPixel(20, STRIP_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show();
Serial.begin(9600);
randomSeed(analogRead(A4));
}
char serialData[30];
void loop(){
// checks to see what has been sent from bt
int mode= 0;
int data[9];
if(Serial.available() > 0)
{
Serial.readBytesUntil('\0', serialData, 30);
switch(serialData[0])
{
case 's':
mode = 1;
parseCommand(serialData, data);
break;
case 'p':
mode = 2;
parseCommand(serialData, data);
break;
case 'c':
mode = 3;
parseCommand(serialData, data);
break;
case 'r':
mode = 4;
parseCommand(serialData, data);
break;
case 't':
mode = 5;
parseCommand(serialData, data);
break;
case 'h':
mode = 6;
parseCommand(serialData, data);
break;
}
// always echo
Serial.write(serialData);
// end of message is maked with a \0
Serial.print('\0');
// clear serialData array
memset(serialData, 0, sizeof(serialData));
}
while (mode == 1 && Serial.available() < 1) {
solidColor(data[0],data[1],data[2]);
}
while (mode == 2 && Serial.available() < 1) {
pulseColor(data[0],data[1],data[2],data[3]);
}
while (mode == 3 && Serial.available() < 1) {
colorFill(data[0],data[1],data[2],data[3]);
}
while (mode == 4 && Serial.available() < 1) {
rainbowCycle(data[0]);
}
while (mode == 5 && Serial.available() < 1) {
twinkle(data[0],data[1],data[2],data[3],data[4]);
}
while (mode == 6 && Serial.available() < 1) {
colorChaser(data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7],data[8]);
}
}
//solid---
//pulse---
//color chaser!!!!!!!!!!!!!!!!(cr1,cg1,cb1,cr2,cg2,cb2,n1,n2,time)
//rainbow----
//twinkle----
//color fill----
void colorChaser(int cr1, int cg1, int cb1,int cr2, int cg2, int cb2,int n1, int n2, int d) {
}
void twinkle(int cr, int cg, int cb,int n, int d) {
for(int i=0; i<n; i++) {
strip.setPixelColor(random(strip.numPixels()), cr, cg, cb);
}
strip.show();
delay(d);
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, 0,0,0);
}
strip.show();
}
void solidColor(int cr, int cg, int cb) {
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, cr, cg, cb);
}
strip.show();
}
void pulseColor(int cr, int cg, int cb, int d) {
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, cr, cg, cb);
}
strip.show();
delay(d);
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, 0,0,0);
}
strip.show();
}
void colorFill(int cr, int cg, int cb, int d) {
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, cr, cg, cb);
strip.show();
delay(d/strip.numPixels());
}
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
delay(d/strip.numPixels());
}
}
//not my code
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
}
void parseCommand(char* command, int* returnValues)
{
// parsing state machine
byte i = 2, j = 0, sign = 0;
int temp = 0;
while(*(command + i) != '\0')
{
switch(*(command + i))
{
case ',':
returnValues[j++] = sign?-temp:temp;
sign = 0;
temp = 0;
break;
case '-':
sign = 1;
break;
default:
temp = temp * 10 + *(command + i) - 48;
}
i++;
}
// set last return value
returnValues[j] = sign?-temp:temp;
}
This is how I wired it
Pin :
mod - n/u
cts - ground
txo - digital pin 0 (rx) on arduino
rx1 - digital pin 1 (tx) on arduino
Vin - 5v
rts - n/u
gnd -ground
dfu - n/u
The code was created by my friend
upload the code to arduino and connect to the module via uart through the le connect app. And under type in the following values depending on the function desired
Functions
//solid---
s,r,g,b
//pulse---
p,r,g,b,delay(ms)
//rainbow----
r,speed(ms)
//twinkle----
t,r,g,b,(number to light),delay(ms)
//color fill----
c,r,g,b,(time to fill strip)
Code
#include <Adafruit_NeoPixel.h>
#define STRIP_PIN A3
Adafruit_NeoPixel strip = Adafruit_NeoPixel(20, STRIP_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show();
Serial.begin(9600);
randomSeed(analogRead(A4));
}
char serialData[30];
void loop(){
// checks to see what has been sent from bt
int mode= 0;
int data[9];
if(Serial.available() > 0)
{
Serial.readBytesUntil('\0', serialData, 30);
switch(serialData[0])
{
case 's':
mode = 1;
parseCommand(serialData, data);
break;
case 'p':
mode = 2;
parseCommand(serialData, data);
break;
case 'c':
mode = 3;
parseCommand(serialData, data);
break;
case 'r':
mode = 4;
parseCommand(serialData, data);
break;
case 't':
mode = 5;
parseCommand(serialData, data);
break;
case 'h':
mode = 6;
parseCommand(serialData, data);
break;
}
// always echo
Serial.write(serialData);
// end of message is maked with a \0
Serial.print('\0');
// clear serialData array
memset(serialData, 0, sizeof(serialData));
}
while (mode == 1 && Serial.available() < 1) {
solidColor(data[0],data[1],data[2]);
}
while (mode == 2 && Serial.available() < 1) {
pulseColor(data[0],data[1],data[2],data[3]);
}
while (mode == 3 && Serial.available() < 1) {
colorFill(data[0],data[1],data[2],data[3]);
}
while (mode == 4 && Serial.available() < 1) {
rainbowCycle(data[0]);
}
while (mode == 5 && Serial.available() < 1) {
twinkle(data[0],data[1],data[2],data[3],data[4]);
}
while (mode == 6 && Serial.available() < 1) {
colorChaser(data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7],data[8]);
}
}
//solid---
//pulse---
//color chaser!!!!!!!!!!!!!!!!(cr1,cg1,cb1,cr2,cg2,cb2,n1,n2,time)
//rainbow----
//twinkle----
//color fill----
void colorChaser(int cr1, int cg1, int cb1,int cr2, int cg2, int cb2,int n1, int n2, int d) {
}
void twinkle(int cr, int cg, int cb,int n, int d) {
for(int i=0; i<n; i++) {
strip.setPixelColor(random(strip.numPixels()), cr, cg, cb);
}
strip.show();
delay(d);
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, 0,0,0);
}
strip.show();
}
void solidColor(int cr, int cg, int cb) {
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, cr, cg, cb);
}
strip.show();
}
void pulseColor(int cr, int cg, int cb, int d) {
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, cr, cg, cb);
}
strip.show();
delay(d);
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, 0,0,0);
}
strip.show();
}
void colorFill(int cr, int cg, int cb, int d) {
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, cr, cg, cb);
strip.show();
delay(d/strip.numPixels());
}
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
delay(d/strip.numPixels());
}
}
//not my code
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
}
void parseCommand(char* command, int* returnValues)
{
// parsing state machine
byte i = 2, j = 0, sign = 0;
int temp = 0;
while(*(command + i) != '\0')
{
switch(*(command + i))
{
case ',':
returnValues[j++] = sign?-temp:temp;
sign = 0;
temp = 0;
break;
case '-':
sign = 1;
break;
default:
temp = temp * 10 + *(command + i) - 48;
}
i++;
}
// set last return value
returnValues[j] = sign?-temp:temp;
}
Please be positive and constructive with your questions and comments.