With this script I want to change between 3 modes of LED illumination. I want to change between them radiocontrolled. I use a futaba. Signal from the Futaba receiver goes to pin2 of the aruino. The output of the receiver CH5 works correct, I tested with a servo. When I try to switch between the modes on the transmitter, the LED's do not change. Er there some error in the script?     // Certainly! Here is the modified script with the updated onRCInputChange function:

#include <FastLED.h>

#define LED_PIN 6
#define COLOR_ORDER GRB
#define CHIPSET WS2811
#define NUM_LEDS 30

#define BRIGHTNESS 100
#define FRAMES_PER_SECOND 60

#define RC_INPUT_PIN 2

bool gReverseDirection = false;

int currentPalette = 0;
int mode = 0;

CRGB leds[NUM_LEDS];

CRGBPalette16 gPal;

void setup() {
  delay(3000); // sanity delay
  FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(BRIGHTNESS);

  pinMode(RC_INPUT_PIN, INPUT); // Configure RC input pin
  attachInterrupt(digitalPinToInterrupt(RC_INPUT_PIN), onRCInputChange, CHANGE); // Register interrupt for RC input changes

  // Palette setup
  gPal = CRGBPalette16(CRGB::Red, CRGB::Red, CRGB::Yellow, CRGB::White);
}

void loop() {
  // No need to check button state anymore
  
  // Update palette based on mode
  switch (mode) {
    case 0:
      gPal = CRGBPalette16(CRGB::Red, CRGB::Red, CRGB::Yellow, CRGB::White);
      break;
    case 1:
      gPal = CRGBPalette16(CRGB::Aqua, CRGB::Blue, CRGB::Aqua, CRGB::White);
      break;
    case 2:
      gPal = CRGBPalette16(CRGB::Green, CRGB::Green, CRGB::Yellow);
      break;
  }

  Fire2012WithPalette(); // run simulation frame, using palette colors

  FastLED.show(); // display this frame
  FastLED.delay(500 / FRAMES_PER_SECOND);
}

#define COOLING  55
#define SPARKING 120

//********************************************************************************************//
// PLAY WITH FALLING, COOLING AND SPARKLING

void Fire2012WithPalette() {
  // Array of temperature readings at each simulation cell
  static uint8_t heat[NUM_LEDS];

  // Step 1. Cool down every cell a little
  for (int i = 0; i < NUM_LEDS; i++) {
    heat[i] = qsub8(heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
  }

  // Step 2. Heat from each cell drifts ‘up’ and diffuses a little
 for(int k = NUM_LEDS - 1; k >= 2; k--) {
    heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3;
  }

  // Step 3. Randomly ignite new ‘sparks’ of heat near the bottom
  if (random8() < SPARKING) {
    int y = random8(7);
    heat[y] = qadd8(heat[y], random8(160, 255));
  }

  // Step 4. Map from heat cells to LED colors
  for (int j = 0; j < NUM_LEDS; j++) {
    // Scale the heat value from 0-255 down to 0-240
    // for best results with color palettes.
    uint8_t colorindex = scale8( heat[j], 240); // Corrected line
    CRGB color = ColorFromPalette( gPal, colorindex);
    int pixelnumber;
    if( gReverseDirection ) {
      pixelnumber = (NUM_LEDS-1) - j;
    } else {
      pixelnumber = j;
    }
    leds[pixelnumber] = color;
  } // Your fire animation code here
}

void onRCInputChange() {
  // Read the RC input to determine the mode
  int switchPosition = digitalRead(RC_INPUT_PIN);

  if (switchPosition == LOW) {
    mode = 0; // Position 1 on the switch
  } else if (switchPosition == HIGH) {
    mode = 2; // Position 3 on the switch
  } else {
    mode = 1; // Position 2 on the switch
  }
}


// Please note that you might need to adjust the RC_INPUT_PIN value to match the pin you are using for the switch input on your Arduino.