Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 12 of 12

Thread: FastLED, SK6805, Teensy 4.1 and a Teensy rookie = full white only

  1. #1
    Junior Member
    Join Date
    Oct 2021
    Posts
    10

    FastLED, SK6805, Teensy 4.1 and a Teensy rookie = full white only

    Hi there, I am new to the Teensy world (while somewhat experienced with Arduinos and ESP32s) and doing my very first steps on the Teensy 4.1.

    I tried to play a little with three SK6805 RGB LEDs, the FastLED lib and the Teensy. THe following sketch ran on an Arduino Nano (except different pin names and no debug output) as I expected, but on the Teensy I only see the LEDs in stable bright white:
    Code:
    #include <Arduino.h>
    #include <FastLED.h>
    
    #define DATA_PIN 1
    #define NUM_LEDS 3
    
    CRGB leds[NUM_LEDS];
    bool LEDSTATE(false);
    
    void setup() {
      Serial.begin(115200);
      Serial.println("--OK--");
    
      FastLED.addLeds<SK6812, DATA_PIN, RGB>(leds, NUM_LEDS); 
      FastLED.setBrightness(25);
      leds[1] = CRGB::Black;
      leds[2] = CRGB::Black;
      pinMode(LED_BUILTIN, OUTPUT);
      digitalWrite(LED_BUILTIN, LOW);
    }
    
    void loop() {
      static uint32_t tic = millis();
    
      if (millis() - tic >= 1000) {
        digitalWrite(LED_BUILTIN, LEDSTATE ? HIGH : LOW);
        LEDSTATE = !LEDSTATE;
        // Turn the LED on with a random color
        uint8_t red = random8();
        uint8_t green = random8();
        uint8_t blue = random8();
        Serial.printf("R=%3d G=%3d B=%3d\n", red, green, blue);
        leds[0].setRGB(red, green, blue);
        // Now shift the LED
        leds[2] = leds[1];
        leds[1] = leds[0];
        // Update!
        FastLED.show();
        tic = millis();
      }
    }
    What am I missing here?

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,081
    I was able to reproduce the problem.

    Click image for larger version. 

Name:	fastledbug.jpg 
Views:	8 
Size:	53.4 KB 
ID:	26158

    Looks like a bug. Teensy LC, 3.2, 3.5, 3.6 work, but Teensy 4.0, 4.1 give bright white no matter what data is used.

    I will investigate later today.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,081
    Yup, it's a bug in FastLED.

    If you're using version 3.003.003 (which ships with Teensyduino) here is a fix.
    Attached Files Attached Files

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,081
    If you're using the latest 3.004.000 version, this will fix the bug.
    Attached Files Attached Files

  5. #5
    Junior Member
    Join Date
    Oct 2021
    Posts
    10
    Thanks a lot, I will try tomorrow.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,081
    Ugh, looks like there may be *another* bug which is limiting the output to only 3 LEDs. Looking into it now....

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,081
    Ok, here is a fix for both bugs using FastLED 3.004.000
    Attached Files Attached Files

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,081
    I submitted a pull request to FastLED. Hopefully they will merge it so this problem will be fixed for all future versions.

    https://github.com/FastLED/FastLED/pull/1306

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,081
    Also, if you just want the LEDs to work, you could also try the WS2812Serial library and FastLED driver.

    First, you need the includes like this (in this order):

    Code:
    #include <WS2812Serial.h>
    #define USE_WS2812SERIAL
    #include <FastLED.h>
    Then for FastLED.addLeds, use WS2812SERIAL rather than WS2812, like this:

    Code:
      FastLED.addLeds<WS2812SERIAL, DATA_PIN, GBR>(leds, NUM_LEDS);
    The 2 downsides are only certain pins are supported by WS2812Serial (only the serial transmit pins) and this uses more memory. But it gives you a highly reliable DMA-based transmit, and it will work without needing to apply those patches the fix the timing bugs in FastLED's bitbang driver.

  10. #10
    Junior Member
    Join Date
    Oct 2021
    Posts
    10
    Would that work for the SK6805 as well?

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,081
    Should work.

  12. #12
    Junior Member
    Join Date
    Oct 2021
    Posts
    10
    Quote Originally Posted by PaulStoffregen View Post
    Should work.
    It does.

    Thanks a lot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •