Last active
July 11, 2021 10:29
-
-
Save chemdoc77/8b50f86d3bef8e777ccca62759efbd2f to your computer and use it in GitHub Desktop.
FastLED and Teensy 4.0 Parallel Output Procedure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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:
I had the same problem on Teensy 4.0. Turning down the refresh rate worked for me.
FastLED.setMaxRefreshRate(FramesPerSecond)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.