platformio / platform-atmelavr

Atmel AVR: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/atmelavr
Apache License 2.0
136 stars 104 forks source link

No light with FastLED, WS2812B and Arduino in PlatformIO (but with ArduinoIDE) #273

Open blue66moon opened 2 years ago

blue66moon commented 2 years ago

Hi MCU experts. I am quite new in the Arduino and PlatformIO universe, and I am faced with a strange issue. I am trying to address a WS2812B LED strip on an Arduino Uno R3 using the FastLED library. There is no problem when I use the ArduinoIDE, but I get no light at all when I use the PlatformIO with Visual Studio Code.

Experimental setup:

I checked the output with a logic analyzer. When I compiled with ArduinoIDE I get the expected result (0x000000 0xffffff delay 0xffffff 0x000000 etc). The timing of one triple byte (0x000000) is 30µs.

Same sample compiled with PlatformIO results in no light. But with logic analyzer I see 0x000000 0x000000 delay 0x000000 0x000000 etc. The timing is a little bit different: 46µs for a triple byte (0x000000). All bits are well-formed zero bits.

Where is my mistake? Or is this a bug? I can't believe that I'm the first one using PlatformIO for Arduino with FastLED library. Thanks in advance.

This issue was posted first at platformio.org: https://community.platformio.org/t/no-light-with-fastled-ws2812b-and-arduino-in-platformio-but-with-arduinoide/25508/7

Full sample code:

#include <FastLED.h>

#define NUM_LEDS 2
#define DATA_PIN 6

CRGB leds[NUM_LEDS];

void setup() {
   delay(2000);
   FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);  // GRB ordering is typical
}

void loop() {
   for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1) {
      leds[whiteLed] = CRGB::White;
      FastLED.show(100);
      delay(100);
      leds[whiteLed] = CRGB::Black;
   }
}