Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chemdoc77/2994b935d333c0c8cbf68d4d7782f6b3 to your computer and use it in GitHub Desktop.
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.
// 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);
}
}
@chemdoc77
Copy link
Author

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