2x Bluno Beetle bluetooth connection + ws2812b + delay

Hi!
I successfully connected two Bluno Beetle together wirelessly.
One have connected potentiometer
Second one have 80LEDS ws2812b strip (neopixel).
I'm on Arduino 1.8.1, Bluno Beetle's are updated.
I'm sending data from potentiometer to second Bluno to wirelessly change hue of the strip.
Everything works great if i have 4-5 LEDS but with 80 leds connected the Serial Buffer somehow gets filled and data sending becomes laggish.
The only think i found to solve this problem is to create delay on master Bluno but i would like the refreshment of the LEDS to be immediate.
Cannot solve this problem alone... Big thanks for help!!!
MASTER CODE
[code]
int sensorPin = 3;
void setup()
{
Serial.begin(115200);
}
void loop()
{
int sensorValue = map(analogRead(sensorPin),0,1023,0,255);
Serial.write(sensorValue);
delay(350);
}
[/code]
SLAVE CODE
[code]
#include "FastLED.h"
#define NUM_LEDS 80
#define CHIPSET WS2812B
#define COLOR_ORDER GRB
#define LED_PIN 5
#define MAX_BRIGHTNESS 165 // Thats full on, watch the power!
#define MIN_BRIGHTNESS 4
#define KOLOR_GORA Candle;
CRGB leds[NUM_LEDS];
void setup()
{
Serial.begin(115200);
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip);
FastLED.setBrightness(MAX_BRIGHTNESS);
FastLED.setDither( 0 );
}
void loop()
{
if (Serial.available())
{
int inbyte = Serial.read();
Serial.println(inbyte);
if(inbyte > 0){
// FastLED.setBrightness(constrain(inbyte, MIN_BRIGHTNESS, MAX_BRIGHTNESS));
turn_hue(inbyte);
}
else {
turn_off();
}
//
}
}
int turn_hue(int x) {
for (int i=40; i > 0 ; --i){
leds[i].setHSV( x+i*0.5, 200, MAX_BRIGHTNESS);
FastLED.show();
leds[80-i].setHSV( x+i*0.5, 200, MAX_BRIGHTNESS);
FastLED.show();
}
}
void turn_off() {
for (int i=40; i > 0 ; --i){
leds[i]= CRGB(0,0,0);
FastLED.show();
leds[80-i]= CRGB(0,0,0);
FastLED.show();
}
}
[/code]
I successfully connected two Bluno Beetle together wirelessly.
One have connected potentiometer
Second one have 80LEDS ws2812b strip (neopixel).
I'm on Arduino 1.8.1, Bluno Beetle's are updated.
I'm sending data from potentiometer to second Bluno to wirelessly change hue of the strip.
Everything works great if i have 4-5 LEDS but with 80 leds connected the Serial Buffer somehow gets filled and data sending becomes laggish.
The only think i found to solve this problem is to create delay on master Bluno but i would like the refreshment of the LEDS to be immediate.
Cannot solve this problem alone... Big thanks for help!!!
MASTER CODE
[code]
int sensorPin = 3;
void setup()
{
Serial.begin(115200);
}
void loop()
{
int sensorValue = map(analogRead(sensorPin),0,1023,0,255);
Serial.write(sensorValue);
delay(350);
}
[/code]
SLAVE CODE
[code]
#include "FastLED.h"
#define NUM_LEDS 80
#define CHIPSET WS2812B
#define COLOR_ORDER GRB
#define LED_PIN 5
#define MAX_BRIGHTNESS 165 // Thats full on, watch the power!
#define MIN_BRIGHTNESS 4
#define KOLOR_GORA Candle;
CRGB leds[NUM_LEDS];
void setup()
{
Serial.begin(115200);
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip);
FastLED.setBrightness(MAX_BRIGHTNESS);
FastLED.setDither( 0 );
}
void loop()
{
if (Serial.available())
{
int inbyte = Serial.read();
Serial.println(inbyte);
if(inbyte > 0){
// FastLED.setBrightness(constrain(inbyte, MIN_BRIGHTNESS, MAX_BRIGHTNESS));
turn_hue(inbyte);
}
else {
turn_off();
}
//
}
}
int turn_hue(int x) {
for (int i=40; i > 0 ; --i){
leds[i].setHSV( x+i*0.5, 200, MAX_BRIGHTNESS);
FastLED.show();
leds[80-i].setHSV( x+i*0.5, 200, MAX_BRIGHTNESS);
FastLED.show();
}
}
void turn_off() {
for (int i=40; i > 0 ; --i){
leds[i]= CRGB(0,0,0);
FastLED.show();
leds[80-i]= CRGB(0,0,0);
FastLED.show();
}
}
[/code]
2017-02-08 03:01:30 @Wendy.Hu thank you for Your answer.
But when i have 4-5 leds the data sending is flawless and works without any delay. With more LEDs I'm not sending more data. It is the same that with 4 LEDs. I think that with more LEDs, in the time that all LEDs light up the data is still sending and after it light's up it gets the data from the buffer except to avoid the data that was send during the light up.
kudlatyy
But when i have 4-5 leds the data sending is flawless and works without any delay. With more LEDs I'm not sending more data. It is the same that with 4 LEDs. I think that with more LEDs, in the time that all LEDs light up the data is still sending and after it light's up it gets the data from the buffer except to avoid the data that was send during the light up.

2017-02-04 22:01:46 Hi
Sorry, the transmission rate of data sent by the master to the slave is 2kb/s, so the problem you encounter are hard to avoid, add a delay is a good way to solve the problem.
Or I would like to suggest you can use the slave to send data to master to see what happened, since the transmission rate of data sent by the slave to the master is 4kb/s.
Hope this will help you.
Wendy.Hu
Sorry, the transmission rate of data sent by the master to the slave is 2kb/s, so the problem you encounter are hard to avoid, add a delay is a good way to solve the problem.
Or I would like to suggest you can use the slave to send data to master to see what happened, since the transmission rate of data sent by the slave to the master is 4kb/s.
Hope this will help you.

