Hi, your library is really helping! Such a great job. I am trying now to send some data via serial, 8 parameters. This will be used to display some levels of different sensors.
Everything seems to be working fine, but if I include FastLED.show(); it begins to lose packages, and the communication becomes patchy.
This is my code, I wonder if you could recommend another way of doing this?
byte values[8];
#include “FastLED.h” // FastLED library. Preferably the latest copy of FastLED 2.1.
#if FASTLED_VERSION < 3001000 // This guarantees the person will have to use FastLED 3.1
#error “Requires FastLED 3.1 or later; check github for latest code.”
#endif
// Fixed definitions cannot change on the fly.
#define LED_DT 6 // Data pin to connect to the strip.
#define COLOR_ORDER GRB // Use BGR for APA102 and GRB for WS2812
#define LED_TYPE WS2812B // Or WS2812. Don’t forget to change the FastLED.addLeds line as well.
#define NUM_LEDS 120 // Number of LED’s.
// Initialize changeable global variables.
uint8_t max_bright = 64; // Overall brightness definition.
struct CRGB leds[NUM_LEDS]; // Initialize our LED array.
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
FastLED.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS); // Use this for WS2812B
FastLED.setBrightness(max_bright);
}
void loop() {
while (Serial1.available() > 0) {
if (Serial1.read() == 80) {
delay(5);
if (Serial1.read() == 80) {
delay(5);
for (int i=0; i<8 ;i++){
if (Serial1.available() > 0) {
values[i]= Serial1.read();
delay(5);
}
}
for (int i=0; i<8 ;i++) {
Serial.println( values[i]);
delay(2);
}
Serial.println("/////////////////////////////");
delay(2);
}
}
}
values[2] = map(values[2],0,250,0,NUM_LEDS);
leds[values[2]] = CRGB::White;
fadeToBlackBy( leds, NUM_LEDS, 20); //all leds which have not been turned on specifically
FastLED.show();
}