Alright I was able to follow that article without any bumps. So now I have the two merged, but only the last one is displaying (but according to the article they are both running, I just can't see them both). So the next thing to do I suppose would be to put them in some kind of order, with a timer, which I have no idea where to start to go about that.
Merged code:
#include <FastLED.h>
#define LED_PIN 5
#define NUM_LEDS 12
#define BRIGHTNESS 255
#define LED_TYPE NEOPIXEL
#define COLOR_ORDER GRB
//start of 1st "Fade" effect
CRGB ledsFade[NUM_LEDS];
/////////////////////////////
/////////// Speed ///////////
#define UPDATES_PER_SECOND 36
/////////////////////////////
CRGBPalette16 currentPalette;
TBlendType currentBlending;
extern CRGBPalette16 Preset;
extern const TProgmemPalette16 Preset_p PROGMEM;
void setup() {
setupFade();
setupPush();
}
void loop() {
loopFade();
loopPush();
}
void setupFade() {
delay( 3000 ); // power-up safety delay
FastLED.addLeds<NEOPIXEL, LED_PIN>(ledsFade, NUM_LEDS);
FastLED.setBrightness( BRIGHTNESS );
currentPalette = Preset_p;
currentBlending = LINEARBLEND;
}
void loopFade()
{
static uint8_t startIndex = 0;
startIndex = startIndex + 1;
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++) {
ledsFade[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
////////////////////////////////////////////////////////////
///////////////// Changes the width of each color //////////
colorIndex += 9;
////////////////////////////////////////////////////////////
}
}
const TProgmemPalette16 Preset_p PROGMEM =
{ ////////////////////
CRGB::Red,
CRGB::Red,
CRGB::Purple,
CRGB::Purple,
CRGB::Cyan,
CRGB::Cyan,
CRGB::Purple,
CRGB::Purple,
CRGB::Red,
CRGB::Red,
CRGB::Purple,
CRGB::Purple,
CRGB::Cyan,
CRGB::Cyan,
CRGB::Purple,
CRGB::Purple,
/////////////////////
};
//Start of 2nd "Push" effect
#include "FastLED.h"
#define NUM_LEDS 12
#define DATA_PIN 5
// Define the array of leds
CRGB leds[NUM_LEDS];
void setupPush() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
void loopPush()
{
for (int dot = 0; dot < NUM_LEDS; dot++)
{
leds[dot] = CRGB::Red;
FastLED.show();
// clear this led for the next time around the loop
leds[dot] = CRGB::Red;
delay(25);
}
for (int dot = 0; dot < NUM_LEDS; dot++)
{
leds[dot] = CRGB::Red;
FastLED.show();
// clear this led for the next time around the loop
leds[dot] = CRGB::Purple;
delay(25);
}
for (int dot = 0; dot < NUM_LEDS; dot++)
{
leds[dot] = CRGB::Cyan;
FastLED.show();
// clear this led for the next time around the loop
leds[dot] = CRGB::Cyan;
delay(25);
}
for (int dot = 0; dot < NUM_LEDS; dot++)
{
leds[dot] = CRGB::Cyan;
FastLED.show();
// clear this led for the next time around the loop
leds[dot] = CRGB::Purple;
delay(25);
}
}