I have a Teensy 4.1 REV D Audio Board. Teensyduino Loader 1.57-beta1 version 3.1.0. FastLED library was update from 3.1 to 3.5. I have 150 WS2811 LEDs. As far as power, I have 5v 20A power supply, which feeds power to each LED strip. The Teensy is connected to the PC. The sketch is suppose to play a song and turn ON Three LEDs at the same time during small delay. After running the sketch, no all LEDs do what they are supposed to do. The LEDs turn ON but they don't follow the delay. The LEDs closer to LED ZERO seem to follow the delay. On the other hand, the ones far from ZERO blink slower or don't even turn ON at all. Beyond LED 80, nothing shows at all. Once I turn the music off, the three LEDs follow the sketch perfect. Can anyone, please, take a look? Thanks
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioPlaySdWav playSdWav1;
AudioOutputI2S audioOutput;
AudioConnection patchCord1(playSdWav1, 0, audioOutput, 0);
AudioConnection patchCord2(playSdWav1, 1, audioOutput, 1);
AudioControlSGTL5000 sgtl5000_1;
#include "FastLED.h"
//**********************
#define NUM_LEDS 150
#define DATA_PIN 29
#define led_Ini 0
#define led_Med 5
#define led_Fin 15
#define millisec_Pause 50
//**********************
// Define the array of leds
CRGB leds[NUM_LEDS];
#define SDCARD_CS_PIN 10
#define SDCARD_MOSI_PIN 11
#define SDCARD_SCK_PIN 13
void setup() {
FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
Serial.begin(9600);
AudioMemory(8);
sgtl5000_1.enable();
sgtl5000_1.volume(0.45);
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!(SD.begin(SDCARD_CS_PIN))) {
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
delay(1000);
}
elapsedMillis blinkTime;
void loop() {
if (playSdWav1.isPlaying() == false) {
Serial.println("Start playing");
playSdWav1.play("gimme.WAV");
delay(10); // wait for library to parse WAV info
}
// print the play time offset
Serial.print("Playing, now at ");
Serial.print(playSdWav1.positionMillis());
Serial.println(" ms");
// Turn the LED on, then pause
leds[led_Ini] = CRGB::Red;
leds[led_Med] = CRGB::Green;
leds[led_Fin] = CRGB::Blue;
// Now turn the LED off, then pause
FastLED.show();
while ( blinkTime < millisec_Pause) {
}
blinkTime = 0;
// Now turn the LEDs off, then pause
leds[led_Ini] = CRGB::Black;
leds[led_Med] = CRGB::Black;
leds[led_Fin] = CRGB::Black;
FastLED.show();
while ( blinkTime < millisec_Pause) {
}
blinkTime = 0;
}