Hard Time making this (newbie)

Hi Community. Im fairly new to Arduino IDE and a complete newbie to Programming itself.
I got a Pretty Fancy “Aurora Borealis” Effect Sketch from some guy on YouTube. Now i built myself a Module that has 1 Potentiometer(A1) and 3 Buttons (3,4,6). Im trying to implement functions that allow me to Change the ColorPalette with one of the Buttons.

In the following Code you can see some stuff i already tried to put in there. (ColorPalette, Button, CyclePalette() )

#include "FastLED.h"

#define KNOB_PIN  A1  //Pin for the trimpot 10K 
#define BUTTON_1  3   //Button 1 cycles color palettes 

// Variables that remain constant
const byte pinData = A5; // Digital output pin to LED strip
const byte numLeds = 100; // Number of LEDs
struct CRGB leds[numLeds]; // Declare an array that stores each LED's data

uint8_t palette = 0;  //Holds the current color palette.
float knob = 1023.0;  //Holds the percentage of how twisted the trimpot is. Used for adjusting the max brightness.

DEFINE_GRADIENT_PALETTE( cw5 ) {
    0, 203, 21,  1,
  255,  83,  1,  2};

DEFINE_GRADIENT_PALETTE(auroraBorealis) {
    0,   0, 255,  28,
  128, 255,   3,  22,
  192, 247,   1,   9,
  255,   0, 255,  28
};
DEFINE_GRADIENT_PALETTE(auroraBorealiss) {
    0,   0, 127,  0,

};
DEFINE_GRADIENT_PALETTE(cumulusClouds)
{
    0, 152, 164, 155,
   30, 139, 152, 140,
   64, 126, 141, 128,
   92,  80,  95,  82,
  107,  46,  59,  47,
  114,  74,  88,  71,
  123, 110, 124, 102,
  196,  46,  58,  39,
  255,  11,  18,   8
};
DEFINE_GRADIENT_PALETTE(Heat)
{
    0,   0,  0,  0,
   95, 255,  0,  0,
  191, 255,255,  0,
  255, 255,255,255
};
DEFINE_GRADIENT_PALETTE(reds) {
    0,  82,  1,  3,
   79,  20,  1,  1,
  181, 139,  1,  0,
  252,  20,  1,  1,
  255,  20,  1,  1};
  DEFINE_GRADIENT_PALETTE(Blues)
  {
    0,   0,  1,  2,
  148,   1,  7, 24,
  194,   2, 31, 77,
  226,   1,108,144,
  255,   0,237,235};
  DEFINE_GRADIENT_PALETTE( vintage ) {
    0,   4,  1,  1,
   51,  16,  0,  1,
   76,  97,104,  3,
  101, 255,131, 19,
  127,  67,  9,  4,
  153,  16,  0,  1,
  229,   4,  1,  1,
  255,   4,  1,  1};
DEFINE_GRADIENT_PALETTE( greenyellow ) {
    0, 184,109, 23,
  255,   0,  5,  3};
DEFINE_GRADIENT_PALETTE(Greens) {
    0, 109,203, 42,
   10,  83,139, 26,
   21,  60, 90, 14,
   31,  39, 91,  3,
   42,  22, 92,  1,
   53,  21, 75,  5,
   68,  20, 59, 21,
   83,  14, 49, 13,
  105,   9, 40,  7,
  133,   5, 27,  3,
  172,   3, 17,  1,
  205,   4, 14,  1,
  255,   5, 11,  1};
  
// Set the LED strip's overall brightness
byte totalBrightness = 255;
int value;

// Variables that can change
CRGBPalette16 activePalette = auroraBorealis; 
byte paletteIndex = 0; // Current colour from the selected palette
const byte transitionDuration = 3;
const byte noiseAmount = 210; // Higher value = more granular noise
// The smaller the difference between the two values, the more subtle the
// noise's brightness variation will be
const byte minBrightness = 5;
const byte maxBrightness = 255; // If aurora at evening: Min: 4 Max: 25 If not 24 , 255

void setup()
{
  FastLED.addLeds<WS2811, pinData, BRG>(leds, numLeds);
  
  //Defines the buttons pins to be input.
  pinMode(BUTTON_1, INPUT);

  //Write a "HIGH" value to the button pins.
  digitalWrite(BUTTON_1, HIGH);
}

void loop()
{
  knob = analogRead(KNOB_PIN) / 1023.0; //Record how far the trimpot is twisted

  value = analogRead(KNOB_PIN);          //Read and save analog value from potentiometer
  value = map(value, 0, 1023, 0, 255); //Map value 0-1023 to 0-255 (PWM)

  CyclePalette();  //Changes palette for shuffle mode or button press.
  
  // Render the effect into the array leds
  paletteTransition();

  // Oscillate the overall brightness at a specified BPM, within a range aka Wie schnell es hell/dunkel wird (BPM, Min, Max)
  FastLED.setBrightness(value);

  // Display all LED's data (= illuminate the LED strip)
  FastLED.show();
}

void paletteTransition()
{
  // Calculate gradient palette transition steps (in milliseconds)
  static const float interval = ((float)(transitionDuration * 60) / 256) * 1000;

  // Declare a variable that stores the noise (= LED brightness) oscillation
  // speed
  static uint32_t dist;

  // Go through all LEDs in the leds array
  for (int i = 0; i < numLeds; i++)
  {

    // Calculate a Simplex Noise value
    int noise = inoise8(dist - i * noiseAmount, dist + i * noiseAmount) % 255;

    // Scale the noise value into a 0 - 255 brighntess value range
    byte brightness = map(noise, 0, 255, minBrightness, maxBrightness);

    // Write a colour fetched from the gradient palette, its brightness
    // modified by the noise, to the indexed LED
    leds[i] = ColorFromPalette(activePalette, paletteIndex, brightness, LINEARBLEND);
  }

  dist += beatsin8(2, 2, 3);

  EVERY_N_MILLISECONDS(interval)
  {
    // Select the next colour
    if (paletteIndex < 255)
    {
      paletteIndex++;
    }
    if (paletteIndex == 255)
    {
      paletteIndex = 0;
    }
  }
};

uint32_t ColorPalette(float num) {
  switch (palette) {
    case 0: return (num < 0) ? auroraBorealis : auroraBorealis;
    case 1: return (num < 0) ? cw5 : cw5;
    case 2: return (num < 0) ? cumulusClouds : cumulusClouds;
    case 3: return (num < 0) ? Heat : Heat;
    case 4: return (num < 0) ? reds : reds;
    case 5: return (num < 0) ? vintage : vintage;
    default: return auroraBorealis;
  }
}

void CyclePalette() {
  
  //If a button is pushed, it sends a "false" reading
  if (!digitalRead(BUTTON_1)) {

    palette++;     //This is this button's purpose, to change the color palette.

    // if (palette >= sizeof(thresholds) / 2) palette = 0;

    // gradient %= thresholds[palette]; //Modulate gradient to prevent any overflow that may occur.

    delay(350);
  }
}

I Hope someone can help me out here. That CRGB seem to not work with ColorPalette() … and i dont know how to start implementing the brightness function for the Knob (Potentiometer)

i dont know how to start implementing the brightness function for the Knob (Potentiometer)

knob = analogRead(KNOB_PIN) / 1023.0; //Record how far the trimpot is twisted

  value = analogRead(KNOB_PIN);          //Read and save analog value from potentiometer
  value = map(value, 0, 1023, 0, 255); //Map value 0-1023 to 0-255 (PWM)
  FastLED.setBrightness(value);

isn't it working ?

That CRGB seem to not work with ColorPalette(

ColorPallete() takes a float and returns a uint32_t (which actually is a 24-bit color value) what are you trying to do ?

FastLED.setBrightness(value);
Works perfect. Forgot to Mention that.

I took the ColorPalette() Part out of another Sketch. If i Press a Button it should switch from 1 Color Palette to the next one.

As i understand it, the Button should increase the case of ColorPalette() with “palette++;” if the Button is pressed. Then the activePalette should Change according to the ColorPalette() part. Maybe i dont get it Right or think too simple / complex.

Basically:

Button pressed → Palette++; → ColorPalette() case increases by one

I tried doin CRGBPalette16 activePalette = ColorPalette;
but that doesnt seem to work.

Also replacing the

leds = ColorFromPalette(activePalette, paletteIndex, brightness, LINEARBLEND);
line with
leds = ColorFromPalette(ColorPalette, paletteIndex, brightness, LINEARBLEND);
doesnt work.
I removed that uint32_t ColorPalette() part and modified at the CRGBPalette16 part
*_ <em>*CRGBPalette16 activePalette = {   if ( palette == 0) { activePalette = cw5 }   if ( palette == 1) { activePalette = auroraBorealis }   if ( palette == 2) { activePalette = cumulusClouds }   if ( palette == 3) { activePalette = greens }   if ( palette == 4) { activePalette = reds }   if ( palette == 5) { activePalette = vintage } };*</em> _*
“expected primary-expression before ‘if’” error now. Imma Keep trying and edit News in here.
Nevermind i managed to make it work ^^
“CRGBPalette16 activePalette;”
and i put following part into void Loop()
{
* if ( palette == 0) { activePalette = cw5; };*
* if ( palette == 1) { activePalette = auroraBorealis; };*
* if ( palette == 2) { activePalette = cumulusClouds; };*
* if ( palette == 3) { activePalette = Greens; };*
* if ( palette == 4) { activePalette = reds; };*
* if ( palette == 5) { activePalette = vintage; }*
* };*
Thanks for the Help ^^

but that doesnt seem to work.

doesnt work.

This is a tad vague, you need to specify if it results in compile error messages and what they are of it it doesn’t do what you want it to and how it doesn’t.
A lot of the code is not very transparant, even a line like thiscase 3: return (num < 0) ? Heat : Heat;is not a way i would write things and if you yourself are clear about what it should do i suggest you write it as a normal ‘if’ statement, inside a function (not within a declaration) which is the cause of your

“expected primary-expression before ‘if’” error now

Do you have a hardware pull-up resistor on the pin ?pinMode(BUTTON_1, INPUT); or would INPUT_PULLUP be the correct mode for it ?
and eh, what is the purpose of the semi-colon at the end of the function declaration ?

void paletteTransition()
{
  // Calculate gradient palette transition steps (in milliseconds)
  static const float interval = ((float)(transitionDuration * 60) / 256) * 1000;

  // Declare a variable that stores the noise (= LED brightness) oscillation
  // speed
  static uint32_t dist;

  // Go through all LEDs in the leds array
  for (int i = 0; i < numLeds; i++)
  {

    // Calculate a Simplex Noise value
    int noise = inoise8(dist - i * noiseAmount, dist + i * noiseAmount) % 255;

    // Scale the noise value into a 0 - 255 brighntess value range
    byte brightness = map(noise, 0, 255, minBrightness, maxBrightness);

    // Write a colour fetched from the gradient palette, its brightness
    // modified by the noise, to the indexed LED
    leds[i] = ColorFromPalette(activePalette, paletteIndex, brightness, LINEARBLEND);
  }

  dist += beatsin8(2, 2, 3);

  EVERY_N_MILLISECONDS(interval)
  {
    // Select the next colour
    if (paletteIndex < 255)
    {
      paletteIndex++;
    }
    if (paletteIndex == 255)
    {
      paletteIndex = 0;
    }
  }
};

It shouldn’t be there (only at the end of a prototype declaration)