Guten Tag,
Ich habe bei mir einen RGB Strip/WS2812B rumfliegen.
Diesen möchte ich gerne über den ESP 8266 ansteuern und über Blynk steuern.
Nun habe ich vollgendes Problem, ich würde gerne Effekte über Blynk steuern.
Leider bekomme ich die Effekte nicht Sauber zum Laufen.
Bei Google etc habe ich nichts brauchbares gefunden.
Könnte mir eine Person evtl erklären wie ich das machen kann?
MfG
WLAN Passwort und der Token wurden entfernt!!
#define FASTLED_ALLOW_INTERRUPTS 0
#define BLYNK_PRINT Serial
#include "FastLED.h"
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define NUM_LEDS 15
CRGB leds[NUM_LEDS];
#define PIN 4
char auth[] = "";
BlynkTimer timer;
void Rainbow(){
meteorRain(0xff,0xff,0xff,10, 64, true, 50);
}
BLYNK_WRITE(V1)
{
meteorRain(0xff,0xff,0xff,10, 64, true, 100);
FastLED.show();// start the function
Blynk.syncVirtual(V1);
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, "", ""); // YOUR SSID and Password
FastLED.addLeds<WS2812B, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}
void loop()
{
Blynk.run();
timer.run();
Blynk.syncAll();
}
void meteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {
setAll(0,0,0);
for(int i = 0; i < NUM_LEDS+NUM_LEDS; i++) {
// fade brightness all LEDs one step
for(int j=0; j<NUM_LEDS; j++) {
if( (!meteorRandomDecay) || (random(10)>5) ) {
fadeToBlack(j, meteorTrailDecay );
}
}
// draw meteor
for(int j = 0; j < meteorSize; j++) {
if( ( i-j <NUM_LEDS) && (i-j>=0) ) {
setPixel(i-j, red, green, blue);
}
}
showStrip();
delay(SpeedDelay);
}
}
void fadeToBlack(int ledNo, byte fadeValue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
uint32_t oldColor;
uint8_t r, g, b;
int value;
oldColor = strip.getPixelColor(ledNo);
r = (oldColor & 0x00ff0000UL) >> 16;
g = (oldColor & 0x0000ff00UL) >> 8;
b = (oldColor & 0x000000ffUL);
r=(r<=10)? 0 : (int) r-(r*fadeValue/256);
g=(g<=10)? 0 : (int) g-(g*fadeValue/256);
b=(b<=10)? 0 : (int) b-(b*fadeValue/256);
strip.setPixelColor(ledNo, r,g,b);
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[ledNo].fadeToBlackBy( fadeValue );
#endif
}
void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED.show();
#endif
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}
void setAll(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}