After some hours on deleting lines in my Code I have found the problem.

After some hours on deleting lines in my Code I have found the problem. The problem are the number of leds. When I use in the example code for num_leds 3 everything works fine, but when i use 40 up to 200, the leds have flickering. I use Teensy 3.1 96 Mhz with fastled 3.1 Audio Shield and the Audio Wave player code and I have no idea why it makes these problems! Interesting is, that when the music doesnt play at the beginning the effect is slower than when the music plays…
@Mark_Kriegsman @Daniel_Garcia @PaulStoffregen

#include <FastLED.h>

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#define NUM_LEDS 200
CRGB leds[NUM_LEDS];

// GUItool: begin automatically generated code
AudioPlaySdWav playWav1; //xy=154,78
AudioOutputI2S i2s1; //xy=334,89
AudioConnection patchCord1(playWav1, 0, i2s1, 0);
AudioConnection patchCord2(playWav1, 1, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=240,153
// GUItool: end automatically generated code

void setup() {
Serial.begin(9600);
FastLED.addLeds<TM1809, 5, RGB>(leds, NUM_LEDS);
FastLED.setBrightness(20);

AudioMemory(5);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
SPI.setMOSI(7);
SPI.setSCK(14);
if (!(SD.begin(10))) {
    // stop here, but print a message repetitively
    while (1) {
        Serial.println("Unable to access the SD card");
        delay(500);
    }
}

}

void playFile(const char *filename)
{
playWav1.play(filename);
delay(5);
}

uint8_t a = 0;
void loop() {
leds[0] = CHSV(a, 255, 255);
a++;
leds[1] = CHSV(0, 255, a);
FastLED.show();
FastLED.delay(1);

EVERY_N_SECONDS(20)
{
    playFile("SDTEST2.WAV");
}

}

Do any of the libraries you’re using (aside from FastLED) use interrupts? If they do, that could be the root of your problem.

I think the audio library uses interrupts with the audio shield

Yes, the audio library is using interrupts and I would guess that it is firing about once per millisecond and is long enough that it is interfering with writing out led data. Try adding:

#define FASTLED_ALLOW_INTERRUPTS 0

Before you include FastLED. (Note: this may end up interfering with audio playback, if so then your other options are switch to apa102 or use the octows2811 driver (which will use dma to drive out led data)

Thanks Daniel, This was a good idea. After adding the line, the leds are working without problems, but the sound is a little bit slow.
I have installed in my project already TM1809, because it is in a car and i need 12V :frowning: Any other solution to fix this?

I have a solution! I have no idea why it works, but it works. I added your line befor fastled include and I added in setup audiointerrupts();

#define FASTLED_ALLOW_INTERRUPTS 0
#include <FastLED.h>

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#define NUM_LEDS 48
CRGB leds[NUM_LEDS];

// GUItool: begin automatically generated code
AudioPlaySdWav playWav1; //xy=154,78
AudioOutputI2S i2s1; //xy=334,89
AudioConnection patchCord1(playWav1, 0, i2s1, 0);
AudioConnection patchCord2(playWav1, 1, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=240,153
// GUItool: end automatically generated code

void setup() {
Serial.begin(9600);
FastLED.addLeds<TM1809, 5, RGB>(leds, NUM_LEDS);
FastLED.setBrightness(20);

AudioMemory(5);
sgtl5000_1.enable();
sgtl5000_1.volume(0.6);
SPI.setMOSI(7);
SPI.setSCK(14);
if (!(SD.begin(10))) {
    // stop here, but print a message repetitively
    while (1) {
        Serial.println("Unable to access the SD card");
        delay(500);
    }
}
AudioInterrupts();

}

void playFile(const char *filename)
{
playWav1.play(filename);
delay(5);
}

uint8_t a = 0;
void loop() {
leds[0] = CHSV(a, 255, 255);
a++;
leds[1] = CHSV(0, 255, a);
//AudioNoInterrupts();
FastLED.show();

FastLED.delay(1);

EVERY_N_SECONDS(10)
{
    playFile("SDTEST2.WAV");
}

}

It works because now FastLED is completely blocking interrupts while writing led data out and re-enables them when finished.

Thanks @Daniel_Garcia :slight_smile: