slurry bowl
Active member
Hello good people of the forum.
I was having poor results running over 300, WS2811 LEDs on my Teensy 3.2, turns out I needed a resistor on the data output pin.
I then tried a Teensy LC and it worked well as I knew pin 17 was 5V logic, but I couldnt see any difference when I used the other LC pins as outputs and again used a resistor. I used a 20 ohm resistor for 475 LEDs on both 17 and any other pin, with good results, running 2, 475 LED strips.
I then put my Teensy 3.2 on a OctoWS2811 board and was having a hard time getting my favorite code to run on it. I enjoy modifying the Juggle animation within
the FastLED demo reel. I solved this problem by bypassing the ethernet ports and just running data from the Octo's #1 and #22 pins. My code looks smoother then when I had the LC or just the Teensy 3.2
I now want to add a button to scroll through my different animations. Previously I used a library simply called Button but it does not work with Teensy.
I know I need to call for a pull-up resistor and wire up the button to one of the open pins on the OctoW2811. Any advice appreciated on how to do this. Apologies as my current shown code has the prior button library commented out and is kinda messy.
I was having poor results running over 300, WS2811 LEDs on my Teensy 3.2, turns out I needed a resistor on the data output pin.
I then tried a Teensy LC and it worked well as I knew pin 17 was 5V logic, but I couldnt see any difference when I used the other LC pins as outputs and again used a resistor. I used a 20 ohm resistor for 475 LEDs on both 17 and any other pin, with good results, running 2, 475 LED strips.
I then put my Teensy 3.2 on a OctoWS2811 board and was having a hard time getting my favorite code to run on it. I enjoy modifying the Juggle animation within
the FastLED demo reel. I solved this problem by bypassing the ethernet ports and just running data from the Octo's #1 and #22 pins. My code looks smoother then when I had the LC or just the Teensy 3.2
I now want to add a button to scroll through my different animations. Previously I used a library simply called Button but it does not work with Teensy.
I know I need to call for a pull-up resistor and wire up the button to one of the open pins on the OctoW2811. Any advice appreciated on how to do this. Apologies as my current shown code has the prior button library commented out and is kinda messy.
Code:
#include "FastLED.h"
#include <OctoWS2811.h>
//OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);
FASTLED_USING_NAMESPACE
#if FASTLED_VERSION < 3001000
#error "Requires FastLED 3.1 or later; check github for latest code."
#endif
//#define DATA_PIN 1
//#define CLK_PIN 4
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 475
CRGB leds[NUM_LEDS];
CRGBPalette16 gPal;
bool gReverseDirection = false;
#define BRIGHTNESS 90
#define FRAMES_PER_SECOND 120
//#include "Button.h" // Include Button library
//const int buttonPin = 3; // 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>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.addLeds<NEOPIXEL, 1>(leds, NUM_LEDS);
FastLED.addLeds<NEOPIXEL, 22>(leds, NUM_LEDS);
// 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, juggle_mag };
//SimplePatternList gPatterns = { juggle_mag };
//SimplePatternList gPatterns = { Fire2012WithPalette };
//SimplePatternList gPatterns = { confetti_GB };
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, 600);
byte dothue = 180;
for( int i = 0; i < 1; i++) {
leds[beatsin16(i+1,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, 600);
byte dothue = 225;
for( int i = 0; i < 2; 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
Last edited by a moderator: