Anyone got a Red & White candy cane looking code for LED strips??
still learning code here.
Well this code does red and green stripes I believe https://gist.github.com/kriegsman/981cc6f501d30dfd82a7
If you change the places it says “CRGB::Green” to “CRGB::Gray”, you should get the desired effect.
(Why “Gray” and not “White”? Because White is 3X brighter than Red, but Gray is only 2X brighter. White is 0xFFFFFF – FF Red, FF Green, and FF Blue. “Red” is 0xFF0000 – FF red and no green or blue. “Gray” is closer in brightness to Red; Gray is 0x808080 --half power on all three color channels. )
Thanks…thats a cool script.
But does bring up a error with Blend (which i have seen before), i was able to change it to NoBlend and it works. any ideas on this error
Ah yeah. Change it to LINEARBLEND.
(Update: I changed the code posted above, so if you download the updated version, it should be fine as-is now.)
hi this is cool code could it be done so the red would be random colour with random position as iam using it for led christmas tree in the shape of a tree want leds green with random leds changing color iam using neo pixels 92 in shape of try running on a arduino pro any help would be great thanks
Yep, you could definitely adapt it for that. Try first just changing the red to a different color.
A random color might be done like this:
CRGB stripeColor = CHSV( random8(), 255,255);
The have the palette set up with those colors.
You might also want to check out the colorTwinkles example posted here a while back. https://plus.google.com/112916219338292742137/posts/8yh7fi9Sb5i
thanks ill give it a go
iam new to this how do i chage the red lol been looking all afternoon
In the stripes code, this is the line to change:
setupStripedPalette( CRGB::Red, CRGB::Red, CRGB::Green, CRGB::Green);
Replace CRGB::Red with whatever other color you wish; it can be a constant like CRGB::Orange, OR a variable like “stripeColor” as I offered in the previous comment too.
Play around and see what happens!
Cool thanks mark ill play around in morning and let you know what happens thanks for all your help
Hi have tryed thius is the code iam using what iam i doing wrong any help would be great just learning this stuff hope to get better for next xmas light display with everyoines help on here and reading books
#include <FastLED.h>
// Example showing how to make a simple striped color palette,
// and use it to animated blended color bars
#define LED_PIN 13
#define NUM_LEDS 37
CRGB leds[NUM_LEDS];
CRGBPalette16 currentPalette;
void setupStripedPalette( CRGB A, CRGB AB, CRGB B, CRGB BA)
{
// Sets up a palette with alternating stripes of
// colors “A” and “B” – with color “AB” between
// where A fades into B, and color “BA” where B fades
// into A.
// The stripes of “A” are narrower than the stripes of “B”,
// but an equal-width arrangement is also shown.
currentPalette = CRGBPalette16(
A, A, A, A, AB, B, B, B, B, B, B, B, B, B, B, BA
// A, A, A, A, A, A, A, AB, B, B, B, B, B, B, B, BA
);
}
void setup() {
delay( 3000 ); // power-up safety delay
FastLED.addLeds<WS2811,LED_PIN,GRB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
// This example shows stripes with NO gaps between them; the colors
// cross-fade at the boundaries. An additional setup alternative is
// provided that puts a ‘black’ gap between the colors, so they don’t
// bleed into each other if you prefer that.
// Color stripes with NO gaps between them – colors will crossfade
setupStripedPalette( CRGB::stripecolour, CRGB::Red, CRGB::Green, CRGB::Green);
// Color stripes WITH gaps of space (black) between them
//setupStripedPalette( CRGB::Red, CRGB::Black, CRGB::Green, CRGB::Black);
}
void loop()
{
static uint8_t startIndex = 0;
startIndex = startIndex + 2; /* higher = faster motion */
fill_palette( leds, NUM_LEDS,
startIndex, 8, /* higher = narrower stripes */
currentPalette, 255, LINEARBLEND);
FastLED.show();
FastLED.delay(1000 / 60);
}
Try this:
-
Start with the original code.
-
Find this line.
FastLED.delay(1000 / 60); -
Add this code just after it:
EVERY_N_SECONDS( 10 ) {
CRGB stripeColor = CHSV( random8(), 255,255);
setupStripedPalette( stripeColor, stripeColor, CRGB::Green, CRGB::Green);
}
What this should do is: every ten seconds, choose a new color palette. The new color palette should be made up of Green and a new randomly chosen color.
Let us know if it works!
Two other things: First, if you’re going to post a large block of code, paste the code into ‘http://pastebin.com’ and just post a link here; easier to read. And second, I recommend that you also try playing around with some of the other, simpler FastLED examples. Color palettes can be a little confusing, and you might be able to do what you want without them.
Did you check out the Color Holiday Twinkle Lights? Might go well on your project, and even though it also uses palettes, it might be easier to hack. https://plus.google.com/112916219338292742137/posts/8yh7fi9Sb5i
hi thanks have done this but give me base colour of red not green cant work out how to change this base colour to green and sorry just igned up to http://pastebin.com will use this if future
Hi - I am using this code, with some modifications, and it is doing exactly what I want.The only change I need to make is to display this only on a section of the led strip (i.e. exclude the first x leds). Cutting the strip isn’t an option
Can anyone help?
no worries I have worked it out 
Ah great. How’d you do it?
I cheated! I have just put a for loop before the show command that turns the range of lights I’m not using to black. Its most likely not the right way to do it but I just wanted something quick and dirty and it does the job.
I would like to know if there is an elegant way to apply an effect to only a range of LEDs though…I did see a post concerning this somewhere on here but as I only started playing with this yesterday, I couldnt figure out how to apply it to this example.
Heh. That’s not cheating, that’s clever, practical engineering!