Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FastLED conflicts with analogWrite on ESP8266? #896

Open
LucianoPez opened this issue Sep 30, 2019 · 1 comment

Comments

@LucianoPez
Copy link

commented Sep 30, 2019

I've found a weird issue that I cant understand.
Here is a simple code that flash all pixel leds ON and OFF every 250 milliseconds. It works OK until I use the analogWrite function. If I uncomment the analogWrite line, I start to see some individual leds randomly changing color. I've tried different DATA_PIN and different pins on the analogWrite() but still the same. I've tried two different ESP8266 boards (wemos and NodeMcu) and still the same issue.

#include <FastLED.h>

#define DATA_PIN     05
#define CANT    28
#define BRIGHTNESS  150

CRGB leds[CANT];
unsigned long syncLastFlash = 0;
boolean lightOn = true;

void setup()
{
  FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, CANT).setCorrection( TypicalLEDStrip );
  FastLED.setBrightness(BRIGHTNESS);
  //analogWrite(13, 100);  // This line cause some LEDs to randomly change color
}

void loop()
{
  if (millis() - syncLastFlash > 250)
  {
    syncLastFlash = millis();
    lightOn = !lightOn;

    if (lightOn == true)
    {
      for (byte j = 0; j < CANT; j++)
        leds[j] = CRGB(0, 0, 200);
      FastLED.show();
    }

    else
    {
      for (byte j = 0; j < CANT; j++)
        leds[j] = CRGB(0, 0, 0);
      FastLED.show();
    }
  }
}
@seymar

This comment has been minimized.

Copy link

commented Oct 10, 2019

What is the state of your electronics?
i.e. If you are driving a motor with that analogWrite it could suddenly draw a lot of current.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.