I know that they have to be put into the same sketch, So I copy/pasted the second Sketch at the bottom of the first. I know that things can't be called by the same name (setup/loop/leds), but when I start renaming and moving the void setup/void loop around, it starts telling me that things are undefined or that it expected something before...
My coding knowledge is very (very) limited, and I don't really know where to even start to look to get on the right path ![]()
Code merged into one sketch:
#include <FastLED.h>
#define LED_PIN 5
#define NUM_LEDS 12
#define BRIGHTNESS 255
#define LED_TYPE NEOPIXEL
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
/////////////////////////////
/////////// Speed ///////////
#define UPDATES_PER_SECOND 36
/////////////////////////////
CRGBPalette16 currentPalette;
TBlendType currentBlending;
extern CRGBPalette16 Preset;
extern const TProgmemPalette16 Preset_p PROGMEM;
void setup() {
delay( 3000 ); // power-up safety delay
FastLED.addLeds<NEOPIXEL, LED_PIN>(leds, NUM_LEDS);
FastLED.setBrightness( BRIGHTNESS );
currentPalette = Preset_p;
currentBlending = LINEARBLEND;
}
void loop()
{
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++) {
leds[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,
/////////////////////
};
#include "FastLED.h"
#define NUM_LEDS 12
#define DATA_PIN 5
#define CLOCK_PIN 13
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
void loop()
{
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);
}
}