Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CHSV Color Array Example
// CHSV Color Array Example by Chemdoc77
#include <FastLED.h>
#define LED_PIN 6
#define CHIPSET NEOPIXEL
#define NUM_LEDS 24
#define BRIGHTNESS 40
CRGB leds[NUM_LEDS];
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
int leds_done = 0;
uint16_t x=0;
uint8_t colorIndex =0;
uint16_t i=0;
// Custom CHSV Colors
CHSV red ( 0, 255, 255);
CHSV green ( 95, 255, 255);
CHSV blue ( 160, 255, 255);
CHSV cyan ( 127, 255, 255);
CHSV magenta ( 210, 255, 255);
CHSV yellow ( 45, 255, 255);
CHSV white ( 100, 0, 255);
// CHSV Color Array
CHSV CHSV_array[]={red, green, blue, cyan, magenta, yellow, white};
CRGB Array_color= CHSV_array[0];
uint8_t Array_Size = ARRAY_SIZE(CHSV_array);
void setup() {
delay(1000); // sanity delay
FastLED.addLeds<CHIPSET, LED_PIN>(leds, NUM_LEDS);
FastLED.setBrightness( BRIGHTNESS );
FastLED.setMaxPowerInVoltsAndMilliamps(5,1500);
set_max_power_indicator_LED(13);
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
}
void loop() {
CD77_chase_array_color_symet(500,2000 , 3 );
FastLED.delay(100);
}
//============== Function ===============
void CD77_chase_array_color_symet(uint16_t wait1,uint16_t wait_Array , uint8_t dots ) {
//shift pixels
EVERY_N_MILLIS_I( Array_time, 500){
Array_time.setPeriod( wait_Array );
i++;
if (i > Array_Size-1) {i = 0;}
Array_color = CHSV_array[i];
}
for(int i = NUM_LEDS - 1; i >0; i--) {
leds[i] = leds[i-1];
}
//reset
EVERY_N_MILLIS_I( Dot_time, 500) {
Dot_time.setPeriod( wait1 );
leds_done = 0;
}
if(leds_done <dots) {
leds[0] = Array_color;
leds_done = leds_done + 1;
} else {
leds[0] = CRGB::Black;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.