Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 15 of 15

Thread: FastLED not working correctly w/ DemoReel100 over 64 LEDs w/ Teensy 3.2

  1. #1

    FastLED not working correctly w/ DemoReel100 over 64 LEDs w/ Teensy 3.2

    HELLLLO FORUM.

    I hope your warm and well.

    When I upload the DemoReel100 code to my Arudino Uno, I can set the Neopixel count to 300 and
    it works great.

    When I upload the same code to my Teensy 3.2, it does not work as well if I set the pixel count above 64. Only the BPM animation works, the rest of the
    code is silent.

    I am operating at 5V.
    FastLED 3.1.0

    Any help really appreciated.

    Here is the code i am using:

    [CODE]#include "FastLED.h"

    FASTLED_USING_NAMESPACE

    // FastLED "100-lines-of-code" demo reel, showing just a few
    // of the kinds of animation patterns you can quickly and easily
    // compose using FastLED.
    //
    // This example also shows one easy way to define multiple
    // animations patterns and have them automatically rotate.
    //
    // -Mark Kriegsman, December 2014

    #if FASTLED_VERSION < 3001000
    #error "Requires FastLED 3.1 or later; check github for latest code."
    #endif

    #define DATA_PIN 8
    //#define CLK_PIN 4
    #define LED_TYPE WS2811
    #define COLOR_ORDER GRB
    #define NUM_LEDS 64
    CRGB leds[NUM_LEDS];

    #define BRIGHTNESS 96
    #define FRAMES_PER_SECOND 120

    void setup() {
    delay(3000); // 3 second delay for recovery

    // tell FastLED about the LED strip configuration
    FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(led s, NUM_LEDS).setCorrection(TypicalLEDStrip);
    //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_OR DER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

    // set master brightness control
    FastLED.setBrightness(BRIGHTNESS);
    }


    // List of patterns to cycle through. Each is defined as a separate function below.
    typedef void (*SimplePatternList[])();
    SimplePatternList gPatterns = { sinelon, juggle, bpm };

    uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
    uint8_t gHue = 0; // rotating "base color" used by many of the patterns

    void loop()
    {
    // Call the current pattern function once, updating the 'leds' array
    gPatterns[gCurrentPatternNumber]();

    // send the 'leds' array out to the actual LED strip
    FastLED.show();
    // insert a delay to keep the framerate modest
    FastLED.delay(1000/FRAMES_PER_SECOND);

    // do some periodic updates
    EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow
    EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically
    }

    #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

    void nextPattern()
    {
    // add one to the current pattern number, and wrap around at the end
    gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
    }

    void rainbow()
    {
    // FastLED's built-in rainbow generator
    fill_rainbow( leds, NUM_LEDS, gHue, 7);
    }

    void rainbowWithGlitter()
    {
    // built-in FastLED rainbow, plus some random sparkly glitter
    rainbow();
    addGlitter(80);
    }

    void addGlitter( fract8 chanceOfGlitter)
    {
    if( random8() < chanceOfGlitter) {
    leds[ random16(NUM_LEDS) ] += CRGB::White;
    }
    }

    void confetti()
    {
    // random colored speckles that blink in and fade smoothly
    fadeToBlackBy( leds, NUM_LEDS, 10);
    int pos = random16(NUM_LEDS);
    leds[pos] += CHSV( gHue + random8(64), 200, 255);
    }

    void sinelon()
    {
    // a colored dot sweeping back and forth, with fading trails
    fadeToBlackBy( leds, NUM_LEDS, 20);
    int pos = beatsin16(13,0,NUM_LEDS);
    leds[pos] += CHSV( gHue, 255, 192);
    }

    void bpm()
    {
    // colored stripes pulsing at a defined Beats-Per-Minute (BPM)
    uint8_t BeatsPerMinute = 62;
    CRGBPalette16 palette = PartyColors_p;
    uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
    for( int i = 0; i < NUM_LEDS; i++) { //9948
    leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
    }
    }

    void juggle() {
    // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 20);
    byte dothue = 0;
    for( int i = 0; i < 8; i++) {
    leds[beatsin16(i+7,0,NUM_LEDS)] |= CHSV(dothue, 200, 255);
    dothue += 32;
    }
    }
    /CODE]

  2. #2
    Also how can I

    1. erase a previous post.
    2. put my code in correct format.

    thanks

  3. #3
    Junior Member
    Join Date
    Dec 2014
    Posts
    8
    I've copied your code and will fix the display error you had.
    Code:
    #include "FastLED.h"
    
    FASTLED_USING_NAMESPACE
    
    // FastLED "100-lines-of-code" demo reel, showing just a few 
    // of the kinds of animation patterns you can quickly and easily 
    // compose using FastLED.  
    //
    // This example also shows one easy way to define multiple 
    // animations patterns and have them automatically rotate.
    //
    // -Mark Kriegsman, December 2014
    
    #if FASTLED_VERSION < 3001000
    #error "Requires FastLED 3.1 or later; check github for latest code."
    #endif
    
    #define DATA_PIN    8
    //#define CLK_PIN   4
    #define LED_TYPE    WS2811
    #define COLOR_ORDER GRB
    #define NUM_LEDS    64
    CRGB leds[NUM_LEDS];
    
    #define BRIGHTNESS          96
    #define FRAMES_PER_SECOND  120
    
    void setup() {
      delay(3000); // 3 second delay for recovery
      
      // tell FastLED about the LED strip configuration
      FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
      //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
    
      // set master brightness control
      FastLED.setBrightness(BRIGHTNESS);
    }
    
    
    // List of patterns to cycle through.  Each is defined as a separate function below.
    typedef void (*SimplePatternList[])();
    SimplePatternList gPatterns = {  sinelon, juggle, bpm };
    
    uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
    uint8_t gHue = 0; // rotating "base color" used by many of the patterns
      
    void loop()
    {
      // Call the current pattern function once, updating the 'leds' array
      gPatterns[gCurrentPatternNumber]();
    
      // send the 'leds' array out to the actual LED strip
      FastLED.show();  
      // insert a delay to keep the framerate modest
      FastLED.delay(1000/FRAMES_PER_SECOND); 
    
      // do some periodic updates
      EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow
      EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically
    }
    
    #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
    
    void nextPattern()
    {
      // add one to the current pattern number, and wrap around at the end
      gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
    }
    
    void rainbow() 
    {
      // FastLED's built-in rainbow generator
      fill_rainbow( leds, NUM_LEDS, gHue, 7);
    }
    
    void rainbowWithGlitter() 
    {
      // built-in FastLED rainbow, plus some random sparkly glitter
      rainbow();
      addGlitter(80);
    }
    
    void addGlitter( fract8 chanceOfGlitter) 
    {
      if( random8() < chanceOfGlitter) {
        leds[ random16(NUM_LEDS) ] += CRGB::White;
      }
    }
    
    void confetti() 
    {
      // random colored speckles that blink in and fade smoothly
      fadeToBlackBy( leds, NUM_LEDS, 10);
      int pos = random16(NUM_LEDS);
      leds[pos] += CHSV( gHue + random8(64), 200, 255);
    }
    
    void sinelon()
    {
      // a colored dot sweeping back and forth, with fading trails
      fadeToBlackBy( leds, NUM_LEDS, 20);
      int pos = beatsin16(13,0,NUM_LEDS);
      leds[pos] += CHSV( gHue, 255, 192);
    }
    
    void bpm()
    {
      // colored stripes pulsing at a defined Beats-Per-Minute (BPM)
      uint8_t BeatsPerMinute = 62;
      CRGBPalette16 palette = PartyColors_p;
      uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
      for( int i = 0; i < NUM_LEDS; i++) { //9948
        leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
      }
    }
    
    void juggle() {
      // eight colored dots, weaving in and out of sync with each other
      fadeToBlackBy( leds, NUM_LEDS, 20);
      byte dothue = 0;
      for( int i = 0; i < 8; i++) {
        leds[beatsin16(i+7,0,NUM_LEDS)] |= CHSV(dothue, 200, 255);
        dothue += 32;
      }
    }
    This should look better.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,651
    Two things to try.

    1: Add this at the top of your program, *before* the #include "FastLED.h"

    Code:
    #define FASTLED_ALLOW_INTERRUPTS 0
    This is usually the simplest solution, but it had the disadvantage that FastLED will interfere with interrupts used by other libraries. Often that's perfectly fine, but if later need to use other libraries or serial communication, just keep in mind turning off FASTLED_ALLOW_INTERRUPTS can disrupt other stuff.


    2: If that doesn't work, try using WS2811SERIAL for LED_TYPE. It also requires some defines and includes. For an example, in Arduino click File > Examples > WS2812Serial > FastLED_Cylon.

    You may also need to use a different pin, since WS2812Serial only supports certain pins. It also uses more memory. But the advantage of WS2812Serial is you get a very reliable and fully non-blocking WS2812 driver that doesn't stop other libraries from using interrupts.

  5. #5
    daywalker03 I tried your modification but it didnt seem to change anything.

    Paul, I tried both of your recommendations and saw noticeable improvement. By adding the line :
    #define FASTLED_ALLOW_INTERRUPTS 0
    I saw improvement and cleaner patterns. It works reliably until around 200 LED count.

    When I upload the same code to my Arduino UNO. The patterns are much faster. I thought this may be due to clock speed on the Teensy, which I tried to change to no luck.

    Paul, I also tried your second recommendation but when I attempt to run my Juggle animation modifications, it doesnt look good, there are LEDs that are jumped and random colors in the tails.

    Is Teensy designed to run animations on WS2811 strips of 3-600 LEDs? Perhaps there is a different controller?

    thanks so much

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,651
    I don't know why you're seeing different results on different boards. Teensy's CPU is much faster, so why you've seeing slower results is a mystery.

    To answer your question, yes, using 1 pin with WS2811 in FastLED or WS2811Serial, Teensy 3.2 is meant to control up to about 1000 LEDs. Using the 8 parallel outputs of OctoWS2811, Teensy 3.2 can control up to about 5000 LEDs.

    Why you're having trouble with such a small number of LED, I do not know. I can try to answer your questions, but to really help get to the bottom of these sorts of problems requires actually seeing how the hardware is connected, and seeing the actual code you're using. Even then, please keep in mind this is trying to troubleshoot over the internet. But we have a pretty good success rate on this forum, when code and photos are shared. Without those details, it truly is blind guesswork.

    But I can tell you I have personally built a display with 4320 LEDs than updated at 30 Hz video speed, which Teensy 3.2 also played a mono 44.1 kHz 16 bit audio track... both read from a file on a SD card. Teensy 3.2 certainly has the raw capability for controlling thousands of LEDs at video update rates. Whatever problems you're facing, I can tell you with good confidence it isn't due to Teensy lacking the raw capacity.

  7. #7
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,054
    Seeing your wiring diagram and more information about the LEDs which you use could help diagnosing. The Arduino drives everything with 5V. The more modern Teensy outputs a logic level of 3.3V. Some LED arrays need 5V logic level, others work well with 3.3V. There are quick and slow level converters. You see that there are tons of variables and as long as you don’t publish every.single.detail, people can only guess.

  8. #8
    Hey Paul and Theremingenieur.

    Thanks for your assistance thus far.

    Perhaps my Teensy 3.2 suffered some kind of damage. Paul I appreciate your clarity that Teensy can certainly handle this.

    I have the setup running at 5V from a power supply. I am running the latest FastLED 3.2.1.

    The only modification I have made to the FastLED demo reel code is adjusting to pin #6.

    If I do any LED count over 64, things get weird. If I add the #define FASTLED_ALLOW_INTERRUPTS 0 then things improve somewhat, but
    any value over 64 LEDs without the previously mentioned interrupt addition starts to flicker badly. With the interrupt definition, I can get to about 120 LED, before flickering badly.

    I have no 5V cap or series resistor on the output pins.

    Here is my code and a photo. Perhaps I need a new Teensy.

    Code:
    #define FASTLED_ALLOW_INTERRUPTS 0
    
    
    #include <FastLED.h>
    
    FASTLED_USING_NAMESPACE
    
    // FastLED "100-lines-of-code" demo reel, showing just a few 
    // of the kinds of animation patterns you can quickly and easily 
    // compose using FastLED.  
    //
    // This example also shows one easy way to define multiple 
    // animations patterns and have them automatically rotate.
    //
    // -Mark Kriegsman, December 2014
    
    #if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
    #warning "Requires FastLED 3.1 or later; check github for latest code."
    #endif
    
    #define DATA_PIN    6
    //#define CLK_PIN   4
    #define LED_TYPE    WS2811
    #define COLOR_ORDER GRB
    #define NUM_LEDS    64
    CRGB leds[NUM_LEDS];
    
    #define BRIGHTNESS          96
    #define FRAMES_PER_SECOND  120
    
    void setup() {
      delay(3000); // 3 second delay for recovery
      
      // tell FastLED about the LED strip configuration
      FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
      //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
    
      // set master brightness control
      FastLED.setBrightness(BRIGHTNESS);
    }
    
    
    // List of patterns to cycle through.  Each is defined as a separate function below.
    typedef void (*SimplePatternList[])();
    SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm };
    
    uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
    uint8_t gHue = 0; // rotating "base color" used by many of the patterns
      
    void loop()
    {
      // Call the current pattern function once, updating the 'leds' array
      gPatterns[gCurrentPatternNumber]();
    
      // send the 'leds' array out to the actual LED strip
      FastLED.show();  
      // insert a delay to keep the framerate modest
      FastLED.delay(1000/FRAMES_PER_SECOND); 
    
      // do some periodic updates
      EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow
      EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically
    }
    
    #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
    
    void nextPattern()
    {
      // add one to the current pattern number, and wrap around at the end
      gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
    }
    
    void rainbow() 
    {
      // FastLED's built-in rainbow generator
      fill_rainbow( leds, NUM_LEDS, gHue, 7);
    }
    
    void rainbowWithGlitter() 
    {
      // built-in FastLED rainbow, plus some random sparkly glitter
      rainbow();
      addGlitter(80);
    }
    
    void addGlitter( fract8 chanceOfGlitter) 
    {
      if( random8() < chanceOfGlitter) {
        leds[ random16(NUM_LEDS) ] += CRGB::White;
      }
    }
    
    void confetti() 
    {
      // random colored speckles that blink in and fade smoothly
      fadeToBlackBy( leds, NUM_LEDS, 10);
      int pos = random16(NUM_LEDS);
      leds[pos] += CHSV( gHue + random8(64), 200, 255);
    }
    
    void sinelon()
    {
      // a colored dot sweeping back and forth, with fading trails
      fadeToBlackBy( leds, NUM_LEDS, 20);
      int pos = beatsin16( 13, 0, NUM_LEDS-1 );
      leds[pos] += CHSV( gHue, 255, 192);
    }
    
    void bpm()
    {
      // colored stripes pulsing at a defined Beats-Per-Minute (BPM)
      uint8_t BeatsPerMinute = 62;
      CRGBPalette16 palette = PartyColors_p;
      uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
      for( int i = 0; i < NUM_LEDS; i++) { //9948
        leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
      }
    }
    
    void juggle() {
      // eight colored dots, weaving in and out of sync with each other
      fadeToBlackBy( leds, NUM_LEDS, 20);
      byte dothue = 0;
      for( int i = 0; i < 8; i++) {
        leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255);
        dothue += 32;
      }
    }
    Click image for larger version. 

Name:	unnamed.jpg 
Views:	11 
Size:	151.1 KB 
ID:	15247
    Last edited by defragster; 11-28-2018 at 06:13 AM. Reason: edit # code entry

  9. #9
    Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    91
    From the photo, it's not clear [to me] how the LED strip is powered. From an external power supply? Which pin of the T3.2 connects the red wire to?
    Anyway, I'm suspecting a power issue.
    What happens if you set the brightness to 24?
    You could set a current limit as well by this line of code:
    Code:
    FastLED.setMaxPowerInVoltsAndMilliamps(5, 500); // power strip from USB port
    Hope this helps,
    Paul

  10. #10
    From your pic it looks like you're powering your leds via the teensy usb 5v line?

    64 leds, RGB is equivalent to x3 for each colour which is a total of 192 leds. At 20mA max per colour we're looking at ~ 400mA with full brightness. USB tends to provide 500mA to most devices max so you're likely over-drawing your available current. Try separating the power supply. Also, I'm pretty sure your LED strip prefers a 5v communication line. The Teensy LC has a dedicated pin connected to a buffer chip that takes the 3v3 from the Teensy and ups it to 5v. You may want to look at something similar to ensure your data is getting across the whole strip. That may indicate why it's currently working with the Arduino Uno which is native 5v.

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,651
    Those breadboard wires have incredibly thin wire inside. Even if those big red & black wires are from a capable 5V power supply, from the photo it looks like you're trying to run all the current though an orange and black breadboard wire. Those breadboard wires are not suitable for the current used by a long LED strip!

  12. #12
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,651
    To specifically answer this question:

    Quote Originally Posted by slurry bowl View Post
    Perhaps my Teensy 3.2 suffered some kind of damage.
    This is very unlikely.

    Usually hardware damage is all-or-nothing, completely destroying the entire Teensy. In some rare cases, people have reported 1 pin was damaged but the rest still worked. But even in those rare cases, the damaged pin becomes completely non-functional.

    We've answered many hundreds of LED project questions on this forum. By far the most common problem with LED projects is power delivery. It's very easy to underestimate the power supply and wires size needed to correctly power a large number of LEDs.

  13. #13
    Hey forum. Thanks for the replies.

    I power the project from a large variable power supply. The posted code is running at 5V and .28Amps. Lots of the problems resolved
    when I isolated the power, but one remains:

    When I run it off the Arduino, the "slugs" aka the animation which is a modified FastLED juggle code named juggle_perfblue move much faster, occasionally skipping LEDs.
    When I run the code off of the Teensy 3.2, it moves much slower, but looks a little better. When I try to up the LED count to 600 (reason I switched to Teensy) the code skips
    many LEDs on the Teensy and does not look good. My goal being slow and smooth fades. Code:

    [CODE]#define FASTLED_ALLOW_INTERRUPTS 0


    #include "FastLED.h"

    FASTLED_USING_NAMESPACE

    #if FASTLED_VERSION < 3001000
    #error "Requires FastLED 3.1 or later; check github for latest code."
    #endif

    #define DATA_PIN 8
    //#define CLK_PIN 4
    #define LED_TYPE WS2811
    #define COLOR_ORDER GRB
    #define NUM_LEDS 100
    CRGB leds[NUM_LEDS];


    CRGBPalette16 gPal;

    bool gReverseDirection = false;

    #define BRIGHTNESS 50
    #define FRAMES_PER_SECOND 120

    #include "Button.h" // Include Button library
    //const int buttonPin = 7; // Set digital pin used with debounced pushbutton8Button myButton(buttonPin, true, true, 50); // Declare the butto
    void setup() {
    delay(3000); // 3 second delay for recovery

    // tell FastLED about the LED strip configuration
    FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(led s, NUM_LEDS).setCorrection(TypicalLEDStrip);
    //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_OR DER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

    // set master brightness control
    FastLED.setBrightness(BRIGHTNESS);

    gPal = CRGBPalette16( CRGB:: Purple, CRGB::Black, CRGB::Blue, CRGB::Green);
    //gPal = CRGBPalette16( CRGB:: Red, CRGB::Black, CRGB::Red, CRGB::Black);

    }
    //Fire2012WithPalette
    // List of patterns to cycle through. Each is defined as a separate function below.
    typedef void (*SimplePatternList[])();

    //SimplePatternList gPatterns = { rainbow, rainbowuniform, rainbowWEIRD, rainbowWithGlitter, confetti_GB, confetti, juggle, juggle_B, juggle_R, juggle_G, sinelon };
    //SimplePatternList gPatterns = { confetti_GB, confetti_PB,juggle_mag, juggle_lilblue, juggle_B_less,juggle_B_more,juggle_B_lots, juggle_perfblue, juggle_2lilgreen, juggle_4lilgreen,juggle_G, juggle_4lilred,juggle_R_less,
    //juggle_R, sinelon, rainbowWithGlitter, };

    //SimplePatternList gPatterns = { juggle_test, juggle_perfblue };
    SimplePatternList gPatterns = { juggle_perfblue };


    uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
    uint8_t gHue = 0; // rotating "base color" used by many of the patterns

    void loop()
    {
    // Call the current pattern function once, updating the 'leds' array
    gPatterns[gCurrentPatternNumber]();

    // send the 'leds' array out to the actual LED strip
    FastLED.show();
    // insert a delay to keep the framerate modest
    FastLED.delay(1000/FRAMES_PER_SECOND);

    // do some periodic updates
    EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow
    //EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically
    // readbutton(); // check for button press

    }

    #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
    void nextPattern()
    {
    // add one to the current pattern number, and wrap around at the end
    gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
    }

    void rainbow()
    {
    // FastLED's built-in rainbow generator
    fill_rainbow( leds, NUM_LEDS, gHue, 7);
    }


    void rainbowuniform()
    {
    // FastLED's built-in rainbow generator
    fill_rainbow( leds, NUM_LEDS, gHue, 2);
    }

    void rainbowWEIRD()
    {
    // FastLED's built-in rainbow generator
    fill_rainbow( leds, NUM_LEDS, gHue, 30);
    }
    void sinelon()
    {
    // a colored dot sweeping back and forth, with fading trails
    fadeToBlackBy( leds, NUM_LEDS, 20);
    int pos = beatsin16(13,0,NUM_LEDS);
    leds[pos] += CHSV( gHue, 255, 192);
    }

    void confetti()
    {
    // random colored speckles that blink in and fade smoothly
    fadeToBlackBy( leds, NUM_LEDS, 10);
    int pos = random16(NUM_LEDS);
    leds[pos] += CHSV( gHue + random8(64), 250, 250);
    }

    void rainbowWithGlitter()
    {
    // built-in FastLED rainbow, plus some random sparkly glitter
    rainbow();
    addGlitter(80);
    }

    void addGlitter( fract8 chanceOfGlitter)
    {
    if( random8() < chanceOfGlitter) {
    leds[ random16(NUM_LEDS) ] += CRGB::White;
    }
    }
    void juggle_test() {
    // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 60);
    byte dothue = 100;
    for( int i = 0; i < 4; i++) {
    leds[beatsin16(i+1,0,NUM_LEDS)] |= CHSV(dothue, 180, 200);
    //dothue += 32;
    }
    }

    void juggle_4lilgreen() {
    // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 300);
    byte dothue = 100;
    for( int i = 0; i < 4; i++) {
    leds[beatsin16(i+8,0,NUM_LEDS)] |= CHSV(dothue, 180, 200);
    dothue += 32;
    }
    }

    void juggle_4lilred() {
    // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 300);
    byte dothue = 1;
    for( int i = 0; i < 4; i++) {
    leds[beatsin16(i+5,50,NUM_LEDS)] |= CHSV(dothue, 220, 200);
    //dothue += 32;
    }
    }

    void juggle_2lilgreen() {
    // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 300);
    byte dothue = 100;
    for( int i = 0; i < 2; i++) {
    leds[beatsin16(i+1,0,NUM_LEDS)] |= CHSV(dothue, 250, 200);
    //dothue += 32;
    }
    }

    void juggle_perfblue() {
    // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 300);
    byte dothue = 180;
    for( int i = 0; i < 3; i++) {
    leds[beatsin16(i+10,0,NUM_LEDS)] |= CHSV(dothue, 250, 200);
    //dothue += 32;
    }
    }

    void juggle_lilblue() {
    // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 100);
    byte dothue = 180;
    for( int i = 0; i < 3; i++) {
    leds[beatsin16(i+1,0,NUM_LEDS)] |= CHSV(dothue, 250, 200);
    //dothue += 32;
    }
    }

    void juggle_mag() {
    // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 20);
    byte dothue = 225;
    for( int i = 0; i < 3; i++) {
    leds[beatsin16(i+1,0,NUM_LEDS)] |= CHSV(dothue, 250, 200);
    //dothue += 32;
    }
    }

    void juggle_R() {
    // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 20);
    byte dothue = 5;
    for( int i = 0; i < 8; i++) {
    leds[beatsin16(i+1,0,NUM_LEDS)] |= CHSV(dothue, 200, 180);
    //dothue += 32;
    }
    }

    void juggle_G() {
    // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 200);
    byte dothue = 96;
    for( int i = 0; i < 8; i++) {
    leds[beatsin16(i+1,0,NUM_LEDS)] |= CHSV(dothue, 200, 100);
    //dothue += 32;
    }
    }
    void juggle_B_less() {
    // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 240);
    byte dothue = 160;
    for( int i = 0; i < 8; i++) {
    leds[beatsin16(i+1,0,NUM_LEDS)] |= CHSV(dothue, 200, 100);
    //dothue += 32;
    }
    }

    void juggle_R_less() {
    // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 240);
    byte dothue = 5;
    for( int i = 0; i < 8; i++) {
    leds[beatsin16(i+1,0,NUM_LEDS)] |= CHSV(dothue, 200, 180);
    //dothue += 32;
    }
    }

    void juggle_B_more() {
    // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 100);
    byte dothue = 160;
    for( int i = 0; i < 8; i++) {
    leds[beatsin16(i+1,0,NUM_LEDS)] |= CHSV(dothue, 200, 100);
    //dothue += 32;
    }
    }

    void juggle_B_lots() {
    // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 10);
    byte dothue = 160;
    for( int i = 0; i < 8; i++) {
    leds[beatsin16(i+1,0,NUM_LEDS)] |= CHSV(dothue, 200, 100);
    //dothue += 32;
    }
    }

    void juggle_Bsteady() {
    // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 1);
    byte dothue = 160;
    for( int i = 0; i < 240; i++) {
    leds[beatsin16(i+200,0,NUM_LEDS)] |= CHSV(dothue, 200, 55);
    //dothue += 32;
    }
    }

    void juggle() {
    // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 20);
    byte dothue = 0;
    for( int i = 0; i < 8; i++) {
    leds[beatsin16(i+7,0,NUM_LEDS)] |= CHSV(dothue, 200, 100);
    dothue += 32;
    }
    }

    void confetti_GB()
    {
    // random colored speckles, Green and Blue hues only
    // Green = 96, Blue = 160
    uint8_t p = 30; // What percentage of the time to make speckles. [Range 0-100]

    fadeToBlackBy( leds, NUM_LEDS, 10);
    if (random8(100) < p) {
    int pos = random16(NUM_LEDS);
    uint8_t hue = random8(2); // randomly chooses a 0 or 1
    if (hue == 0) {
    hue = random8(92,111); // pick a hue somewhere in the green zone
    } else {
    hue = random8(156,165); // pick a hue somewhere in the blue zone
    }
    leds[pos] += CHSV( hue, random8(200,240), 100);
    }
    }//end confetti_GB

    void confetti_PB()
    {
    // random colored speckles, Green and Blue hues only
    // Green = 96, Blue = 160
    uint8_t p = 70; // What percentage of the time to make speckles. [Range 0-100]

    fadeToBlackBy( leds, NUM_LEDS, 10);
    if (random8(100) < p) {
    int pos = random16(NUM_LEDS);
    uint8_t hue = random8(2); // randomly chooses a 0 or 1
    if (hue == 0) {
    hue = random8(2,80); // pick a hue somewhere in the green zone
    } else {
    hue = random8(156,165); // pick a hue somewhere in the blue zone
    }
    leds[pos] += CHSV( hue, random8(200,240), 100);
    }
    }//end confetti_GB





    // Fire2012 by Mark Kriegsman, July 2012
    // as part of "Five Elements" shown here: http://youtu.be/knWiGsmgycY
    ////
    // This basic one-dimensional 'fire' simulation works roughly as follows:
    // There's a underlying array of 'heat' cells, that model the temperature
    // at each point along the line. Every cycle through the simulation,
    // four steps are performed:
    // 1) All cells cool down a little bit, losing heat to the air
    // 2) The heat from each cell drifts 'up' and diffuses a little
    // 3) Sometimes randomly new 'sparks' of heat are added at the bottom
    // 4) The heat from each cell is rendered as a color into the leds array
    // The heat-to-color mapping uses a black-body radiation approximation.
    //
    // Temperature is in arbitrary units from 0 (cold black) to 255 (white hot).
    //
    // This simulation scales it self a bit depending on NUM_LEDS; it should look
    // "OK" on anywhere from 20 to 100 LEDs without too much tweaking.
    //
    // I recommend running this simulation at anywhere from 30-100 frames per second,
    // meaning an interframe delay of about 10-35 milliseconds.
    //
    // Looks best on a high-density LED setup (60+ pixels/meter).
    //
    //
    // There are two main parameters you can play with to control the look and
    // feel of your fire: COOLING (used in step 1 above), and SPARKING (used
    // in step 3 above).
    //
    // COOLING: How much does the air cool as it rises?
    // Less cooling = taller flames. More cooling = shorter flames.
    // Default 55, suggested range 20-100
    #define COOLING 35

    // SPARKING: What chance (out of 255) is there that a new spark will be lit?
    // Higher chance = more roaring fire. Lower chance = more flickery fire.
    // Default 120, suggested range 50-200.
    #define SPARKING 50


    void Fire2012WithPalette()
    {
    // Array of temperature readings at each simulation cell
    static byte heat[NUM_LEDS];

    // Step 1. Cool down every cell a little
    for( int i = 0; i < NUM_LEDS; i++) {
    heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
    }

    // Step 2. Heat from each cell drifts 'up' and diffuses a little
    for( int k= NUM_LEDS - 1; k >= 2; k--) {
    heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
    }

    // Step 3. Randomly ignite new 'sparks' of heat near the bottom
    if( random8() < SPARKING ) {
    int y = random8(7);
    heat[y] = qadd8( heat[y], random8(160,255) );
    }

    // Step 4. Map from heat cells to LED colors
    for( int j = 0; j < NUM_LEDS; j++) {
    // Scale the heat value from 0-255 down to 0-240
    // for best results with color palettes.
    byte colorindex = scale8( heat[j], 240);
    CRGB color = ColorFromPalette( gPal, colorindex);
    int pixelnumber;
    if( gReverseDirection ) {
    pixelnumber = (NUM_LEDS-1) - j;
    } else {
    pixelnumber = j;
    }
    leds[pixelnumber] = color;
    }
    }


    //BUTTON STUFF
    //---------Function to read the button and do something----------
    //void readbutton() {
    // myButton.read();
    // if(myButton.wasPressed()) {
    // nextPattern(); // Change to the next pattern


    //end_readbutton/CODE]

  14. #14

  15. #15
    Member crees's Avatar
    Join Date
    Dec 2016
    Location
    Utah
    Posts
    94
    I have driven thousands of leds with teensy 3.2 with huge success.

    First may I suggest as others here have and that is you need to run this at 5v logic. Yes you have 5v power but teensy Logic is 3.3v! Save yourself some time and pickup an octows2811 board to covert your pins to 5v logic that the pixels really need. Also I noticed you don’t have any resistors ? . Your signals may end up becoming and issue especially if your sending large amounts of pixel data with no resistors on 3.3v Logic = erratic inconsistent possibilities. Again the octows2811 has the correct resistors and a convenient rj45 breakout for your pixels.

    Last observation when you put your pin headers on I would personally solder all of them in. Leaving some unsoldered could add to more interesting un intended results.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •