Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FastLED and Teensy 4.0 Parallel Output Procedure
/* New Product Test Sketch by Chemdoc77
used to test new RGB LED strips and Matrix that I purchase.
Note: Uses FastLED's Parallel Output procedure to work with a Teensy 4.0
*/
#include <FastLED.h>
#define DATA_PIN 7 // it is critical that you use this pin number or other pin numbers using FastLED's Parallel Output procedure
int brightness = 40;
// Teensy 4.0 Stuff ================
#define NUM_LEDS_PER_STRIP 64
#define NUM_STRIPS 1
#define NUM_LEDS NUM_LEDS_PER_STRIP
CRGB leds[NUM_LEDS_PER_STRIP * NUM_STRIPS];
void setup() {
delay(1000);
// Teensy 4.0 Stuff ==============
FastLED.addLeds<NUM_STRIPS, WS2812B,DATA_PIN,GRB>(leds, NUM_LEDS_PER_STRIP);
//USE for WS2811:
// FastLED.addLeds<NUM_STRIPS, WS2811, DATA_PIN >(leds, NUM_LEDS_PER_STRIP);
FastLED.setBrightness(brightness);
FastLED.setMaxPowerInVoltsAndMilliamps(5, 1500);
set_max_power_indicator_LED(13);
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
}
void loop() {
fill_solid( leds, NUM_LEDS, CRGB::Red);
FastLED.delay(500);
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.delay(500);
fill_solid( leds, NUM_LEDS, CRGB::Blue);
FastLED.delay(500);
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.delay(500);
fill_solid( leds, NUM_LEDS, CRGB::Green);
FastLED.delay(500);
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.delay(500);
fill_solid( leds, NUM_LEDS, CRGB::Yellow);
FastLED.delay(500);
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.delay(500);
cd77_colorwipe_dot(CRGB::Red, 0, NUM_LEDS, 40);
cd77_colorwipe_dot(CRGB::Blue, 0, NUM_LEDS, 40);
cd77_colorwipe_dot(CRGB::Green, 0, NUM_LEDS, 40);
}
//==================== Functions ===============================
void cd77_colorwipe(CRGB color, uint16_t to, uint16_t wait) {
for (uint16_t i = 0; i <to; i++) {
leds[i] = color;
FastLED.delay(500);
}
}
void cd77_colorwipe_line2(CRGB color, uint16_t wait) {
for (uint16_t i = 0; i <NUM_LEDS; i++) {
leds[i] = color;
FastLED.show();
}
}
void cd77_colorwipe_line(CRGB color, uint16_t wait) {
for (uint16_t i = 0; i <NUM_LEDS; i++) {
leds[i] = color;
FastLED.delay(wait);
}
}
void cd77_colorwipe_dot(CRGB color,uint16_t from, uint16_t to, uint16_t wait) {
for (uint16_t i = from; i <to; i++) {
leds[i] = color;
FastLED.delay(wait);
leds[i] = CRGB::Black;
FastLED.show();
}
}
void cd77_colorwipe_dot_fast(CRGB color) {
for (uint16_t i = 0; i <NUM_LEDS; i++) {
leds[i] = color;
FastLED.show();
leds[i] = CRGB::Black;
FastLED.show();
}
}
@TreeDan

This comment has been minimized.

Copy link

@TreeDan TreeDan commented Aug 7, 2020

Thanks CD77! I have 8 50-led ws2811 strings connected for a total of 400 leds. I was using an arduino due with fastled and was able to do a fastled.show() to all 400 with no problem. I just purchased a teensy 4.1 and used this code. Sketch works fine as long as i keep NUM_LEDS_PER_STRIP below 71. Do you know how i can increase to 200! My final project will have 1400 leds and would like to do 7 parallel outputs to 200 leds each to maintain my 100 fps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment