Hello all
i am trying to integrate 2 codes
The idea is to combine a singe color with animation namely, run color for x minutes delay(100060Minutes); and then switch to a short animation and than back to a color, and so on ( loop)
i am trying to combine among functions, since i am very new to programing i keep getting errors
gear: Arduino mega
- ws2812*
i am attaching the codes for your review
any chance someone could assist me with it?
Thanks in advance
study color code:
#define LED_TYPE WS2812B // type of RGB LEDs
#define COLOR_ORDER GRB // sequence of colors in data stream
#define NUM_LEDS 60 // 60 LEDs numbered [0..59]
#define DATA_PIN 5 // LED data pin
#define BRIGHTNESS 88 // brightness range [off..on] = [0..255]
CRGB leds[NUM_LEDS];
#define UPDATES_PER_SECOND 100
CRGBPalette16 currentPalette;
TBlendType currentBlending;
extern CRGBPalette16 myRedWhiteBluePalette;
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;
void setup() {
delay( 3000 ); // power-up safety delay
FastLED.addLeds<LED_TYPE,DATA_PIN , COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
currentPalette = RainbowColors_p;
currentBlending = LINEARBLEND
}
void setup() {
// initialize library using CRGB LED array
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS)
}
void loop() {
// use a routine to fill a block of LEDs with a fixed color
fill_solid( &(leds[0]), 5 /number of leds/, CRGB(51, 220, 255));
fill_solid( &(leds[5]), 5 /number of leds/, CRGB(255, 0,0));
fill_solid( &(leds[10]), 5 /number of leds/, CRGB(255, 140,25));
fill_solid( &(leds[15]), 5 /number of leds/, CRGB(0, 255,255));
fill_solid( &(leds[20]), 5 /number of leds/, CRGB(0, 255,255));
fill_solid( &(leds[25]), 5 /number of leds/, CRGB(01, 255,255));
fill_solid( &(leds[30]), 5 /number of leds/, CRGB(0, 221,255));
fill_solid( &(leds[35]), 5 /number of leds/, CRGB(255, 51,255));
fill_solid( &(leds[40]), 5 /number of leds/, CRGB(0, 255,255));
fill_solid( &(leds[45]), 5 /number of leds/, CRGB(0, 255,255));
fill_solid( &(leds[50]), 5 /number of leds/, CRGB(255, 0,0));
fill_solid( &(leds[55]), 5 /number of leds/, CRGB(0, 255,255));
// activate all changes to LEDs
FastLED.show();
delay (5000);
}
animation patterns
#include <FastLED.h>
#define LED_TYPE WS2812B // type of RGB LEDs
#define COLOR_ORDER GRB
#define LED_PIN 5
#define NUM_LEDS 60
#define BRIGHTNESS 88
#define LED_TYPE WS2812
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
#define UPDATES_PER_SECOND 100
CRGBPalette16 currentPalette;
TBlendType currentBlending;
extern CRGBPalette16 myRedWhiteBluePalette;
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;
void setup() {
delay( 3000 ); // power-up safety delay
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
currentPalette = RainbowColors_p;
currentBlending = LINEARBLEND;
}
void loop()
{
ChangePalettePeriodically();
static uint8_t startIndex = 0;
startIndex = startIndex + 1; /* motion speed */
FillLEDsFromPaletteColors( startIndex);
FastLED.show();
FastLED.delay(1000 / UPDATES_PER_SECOND);
}
void FillLEDsFromPaletteColors( uint8_t colorIndex)
{
uint8_t brightness = 255;
for( int i = 0; i < NUM_LEDS; i++) {
leds = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
-
colorIndex += 3;*
-
}*
}
// There are several different palettes of colors demonstrated here.
//
// FastLED provides several 'preset' palettes: RainbowColors_p, RainbowStripeColors_p,
// OceanColors_p, CloudColors_p, LavaColors_p, ForestColors_p, and PartyColors_p.
//
// Additionally, you can manually define your own color palettes, or you can write
// code that creates color palettes on the fly. All are shown here.
void ChangePalettePeriodically()
{ -
uint8_t secondHand = (millis() / 1000) % 60;*
-
static uint8_t lastSecond = 99;*
-
if( lastSecond != secondHand) {*
-
lastSecond = secondHand;*
-
if( secondHand == 0) { currentPalette = RainbowColors_p; currentBlending = LINEARBLEND; }*
-
if( secondHand == 10) { currentPalette = RainbowStripeColors_p; currentBlending = NOBLEND; }*
-
if( secondHand == 15) { currentPalette = RainbowStripeColors_p; currentBlending = LINEARBLEND; }*
-
if( secondHand == 20) { SetupPurpleAndGreenPalette(); currentBlending = LINEARBLEND; }*
-
if( secondHand == 25) { SetupTotallyRandomPalette(); currentBlending = LINEARBLEND; }*
-
if( secondHand == 30) { SetupBlackAndWhiteStripedPalette(); currentBlending = NOBLEND; }*
-
if( secondHand == 35) { SetupBlackAndWhiteStripedPalette(); currentBlending = LINEARBLEND; }*
-
if( secondHand == 40) { currentPalette = CloudColors_p; currentBlending = LINEARBLEND; }*
-
if( secondHand == 45) { currentPalette = PartyColors_p; currentBlending = LINEARBLEND; }*
-
if( secondHand == 50) { currentPalette = myRedWhiteBluePalette_p; currentBlending = NOBLEND; }*
-
if( secondHand == 55) { currentPalette = myRedWhiteBluePalette_p; currentBlending = LINEARBLEND; }*
-
}*
}
// This function fills the palette with totally random colors.
void SetupTotallyRandomPalette()
{ -
for( int i = 0; i < 16; i++) {*
_ currentPalette = CHSV( random8(), 255, random8());_
* }*
}
Thanks in advance