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

Status
Not open for further replies.

Miq58

Member
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?
 
I was able to reproduce the problem.

fastledbug.jpg

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.
 
Yup, it's a bug in FastLED.

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

Attachments

  • clockless_arm_mxrt1062.h
    3.7 KB · Views: 40
If you're using the latest 3.004.000 version, this will fix the bug.
 

Attachments

  • clockless_arm_mxrt1062.h
    3.7 KB · Views: 35
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.
 
Status
Not open for further replies.
Back
Top