Problems with FastLED.h

Hey, I have problems with my project. I want to have ws2812 leds behind my bed, but my code doesn’t work.

my code:

//#define BLYNK_PRINT Serial  // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "FastLED.h"

#define LED_PIN     D1 // GPIO pin for RGB LEDs.
#define NUM_LEDS    60 // Number of LEDs connected.
#define LED_TYPE    WS2812
#define COLOR_ORDER BRG
struct CRGB leds[NUM_LEDS];  //Initialisieren des LED-Arrays

int r = 0;
int g = 0;
int b = 0;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "21fdd48887ff4b498ada4d724d7c89ae";

uint8_t max_bright = 125;

void setup()
{

  Serial.begin(9600);

  Blynk.begin(auth, "Hope Siebzehn AP", "47275552990710462457");

  LEDS.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setBrightness(max_bright);
  FastLED.clear();
}

// This assumes there is a Blynk RGB widget writing data to virtual pin V1.
BLYNK_WRITE(V1)
{
  r = param[0].asInt();
  g = param[1].asInt();
  b = param[2].asInt();
  Serial.println("test");
}

BLYNK_WRITE(V2) 
{
  Serial.println("Knopf"); 
  fill_solid(leds, NUM_LEDS, CRGB::Red);
  FastLED.show();
}

void loop()
{
  Blynk.run();
  FastLED.show();
}

I think it’s a problem with the Fastled library, but I think you can help me nonetheless. The LEDs work fine, because I tested them with another program that uses the adafruit library. But it’s old and bulky and I want to switch to the much faster fastleds.h library. Any help is much appreciated.

  • Omikron

Where is that function, e.g. fill_solid(); ?

Do you get any errors or anything?

I edited your post too, added ``` before and after your code, it makes is pretty and readable :wink:

And you definitely want to remove fastled.show() from loop()!

Thanks, I will do it myself next time :slight_smile:
I removed fastled.show() from my main loop, but about fill_solid()… Isn’t it some sort of built in function of fastled.h?
At least the documentation says so… I may be confusing something?
I mean, I don’t get any errors, It just doesn’t work when I try to use zergba or a simple button.
FastLED.fill_solid doesn’t work, though.

No, it’s just a function calling, so it has to be defined in your sketch.

Does it work when you use a FastLED example, thus without Blynk?

I will try that.
I mean, the Blynk thyng works and all, but fastled gives me headaches.
Just wait a minute or two, will you?

Edit:

Strange, when I upload my (stolen) test code, nothing happens.
Sady I can’t show it here, something about “new user” and “you can’t have more than to links” or something.

Put this in void setup(); to test if the leds actually work:

   int i;

  for(i=0;i<NUM_LEDS;i++)
  {
    LEDS[i] = CRGB::White;
  }
FastLED.show();

They should light up white if it’s wired ok and so on.

Hey, thanks for the example code, but it gives me this error:

Arduino: 1.8.5 (Linux), Board: “NodeMCU 1.0 (ESP-12E Module), 80 MHz, 4M (1M SPIFFS), v2 Lower Memory, Disabled, None, Sketch + WiFi Settings, 57600”

In file included from /root/Schreibtisch/Testlauf/Testlauf.ino:4:0:
/root/Arduino/libraries/FastLED/FastLED.h:17:21: note: #pragma message: FastLED version 3.001.007

pragma message “FastLED version 3.001.007”

                 ^

In file included from /root/Arduino/libraries/FastLED/FastLED.h:68:0,
from /root/Schreibtisch/Testlauf/Testlauf.ino:4:
/root/Arduino/libraries/FastLED/fastspi.h:110:23: note: #pragma message: No hardware SPI pins defined. All SPI access will default to bitbanged output

pragma message “No hardware SPI pins defined. All SPI access will default to bitbanged output”

                   ^

/root/Schreibtisch/Testlauf/Testlauf.ino: In function ‘void setup()’:
Testlauf:37: error: no match for ‘operator=’ (operand types are ‘CLEDController’ and ‘CRGB::HTMLColorCode’)
LEDS[i] = CRGB::White;
^
/root/Schreibtisch/Testlauf/Testlauf.ino:37:13: note: candidates are:
In file included from /root/Arduino/libraries/FastLED/FastLED.h:50:0,
from /root/Schreibtisch/Testlauf/Testlauf.ino:4:
/root/Arduino/libraries/FastLED/controller.h:39:7: note: CLEDController& CLEDController::operator=(const CLEDController&)
class CLEDController {
^
/root/Arduino/libraries/FastLED/controller.h:39:7: note: no known conversion for argument 1 from ‘CRGB::HTMLColorCode’ to ‘const CLEDController&’
/root/Arduino/libraries/FastLED/controller.h:39:7: note: CLEDController& CLEDController::operator=(CLEDController&&)
/root/Arduino/libraries/FastLED/controller.h:39:7: note: no known conversion for argument 1 from ‘CRGB::HTMLColorCode’ to ‘CLEDController&&’
exit status 1
no match for ‘operator=’ (operand types are ‘CLEDController’ and ‘CRGB::HTMLColorCode’)

I don’t know if it helps you, it does not help me :confused:
Oops, ignore that SPI error, commong thing with fastled but has nothing to do with my problem.

Sooo, I tried it again with this:

leds[i] = CRGB( 50, 100, 150);

It gives me no errors, but it doesn’t work again. Strangely enough, the LEDs work flawlessly with the adafruit library.
What am I doing wrong?

Hello? Anyone there? Might just keep using adafruit’s library.

There are plenty of discussions and examples. Please use google. Closing this.