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. I do not know how to clear buffer or where i make an mistake?
Cannot solve this problem alone... Big thanks for help!!!
MASTER 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);
}
SLAVE 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();
}
}