Last active
August 27, 2019 18:03
-
-
Save chemdoc77/2994b935d333c0c8cbf68d4d7782f6b3 to your computer and use it in GitHub Desktop.
Special Request to fill NeoPixel strip with one third red, one third white and one third blue.
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
// special request - fill NeoPixel strip with one third red, one third white and one third blue. | |
// by Chemdoc77 | |
//This was run on a Teensy 3.6 using the Arduino 1.8.3 and the Teensyduino 1.37 | |
#include "FastLED.h" | |
#define NUM_LEDS 240 | |
#define Data_Pin 6 | |
#define chipset NEOPIXEL | |
#define BRIGHTNESS 20 //set the strips brightness from 1 to 255 | |
CRGB rawleds[NUM_LEDS]; | |
CRGBSet leds(rawleds, NUM_LEDS); | |
CRGBSet leds1(leds(0,79)); | |
CRGBSet leds2(leds(80,159)); | |
CRGBSet leds3(leds(160,239)); | |
struct CRGB * ledarray[] ={leds1, leds2, leds3}; | |
CRGB colorarry[]= {CRGB::Red,CRGB::White, CRGB::Blue}; | |
uint16_t x=0; // needed so one can use x outside of a for statement | |
void setup() { | |
delay(2000); // power-up safety delay | |
FastLED.addLeds<chipset, Data_Pin>(leds, NUM_LEDS); | |
FastLED.setBrightness(BRIGHTNESS); | |
FastLED.setMaxPowerInVoltsAndMilliamps(5,1000); | |
} | |
void loop() { | |
cd77_arrayfill_RWB_all_one_color(3,450); // lights up the whole strip with one color at a time and repeats z times. | |
cd77_arrayfill_RWB_all(450); //lights up each segment and keeps it on until the end of the animation. | |
cd77_arrayfill_RWB_each_alone(450); // lights up each segment and keeps it on until the end of the animation. | |
cd77_arrayfill_RWB_all_each_array_together(3, 450); | |
} | |
//================ New Function ===================== | |
void cd77_arrayfill_RWB_all(uint16_t wait){ | |
for ( x=0; x<3; x++){ | |
fill_solid(ledarray[x], 80, colorarry[x]); | |
FastLED.delay(wait); | |
} | |
fill_solid( leds, NUM_LEDS, CRGB::Black); | |
FastLED.delay(wait); | |
} | |
void cd77_arrayfill_RWB_each_alone(uint16_t wait){ | |
for ( x=0; x<3; x++){ | |
fill_solid(ledarray[x], 80, colorarry[x]); | |
FastLED.delay(wait); | |
fill_solid( ledarray[x], 80, CRGB::Black); | |
FastLED.show(); | |
} | |
} | |
void cd77_arrayfill_RWB_all_one_color(uint16_t repeat, uint16_t wait){ | |
for(uint16_t z=0; z<repeat; z++){ | |
for ( x=0; x<3; x++){ | |
fill_solid( leds, NUM_LEDS, colorarry[x]); | |
FastLED.delay(wait); | |
fill_solid( leds, NUM_LEDS, CRGB::Black); | |
FastLED.delay(wait); | |
} | |
} | |
} | |
void cd77_arrayfill_RWB_all_each_array_together(uint16_t repeat, uint16_t wait){ | |
for(uint16_t z=0; z<repeat; z++){ | |
for ( x=0; x<3; x++){ | |
fill_solid( ledarray[x], 80, colorarry[x]); | |
} | |
FastLED.delay(wait); | |
fill_solid( leds, NUM_LEDS, CRGB::Black); | |
FastLED.delay(wait); | |
} | |
} |
Hi Doug-Manning :
I need to see your sketch so that I can help you. Can you please post your sketch on either Pastbin or GitHub Gist and send me the link so that I can help you.
Best Regards,
Chemdoc77
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I realize that this is Last Active 2 years ago, but I'm hoping to get a bit lucky! I tried using the color array in line 21 (with my own color list), but my colors do not come out correct. I'm pretty sure that this is because my LED strip is Color order GRB not RGB. If I use fill_solid ( leds, NUM_LEDS, CRGB::Red) ot works, but if I use fill_solid ( leds, NUM_LEDS, colorarry[0]) it isn't red! Any suggestions?
Thanks in advance