#define DECODE_NEC        // DECODE_NEC
#include <IRremote.hpp>   // Do not change header order.
#include <Adafruit_NeoPixel.h>

enum class State : byte { irRemote, checkCode };

namespace gc {
constexpr uint8_t irReceivePin {7};
constexpr uint8_t neoPixelPin {8};
constexpr uint8_t numPixels {24};
}   // namespace gc

Adafruit_NeoPixel pixels(gc::numPixels, gc::neoPixelPin, NEO_GRB + NEO_KHZ800);
uint8_t brightness {255};

uint16_t irReceive() {
  uint16_t received {0};

  if (IrReceiver.decode()) {
    IrReceiver.printIRResultShort(&Serial);
    if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
      // We have an unknown protocol here, print more info
      IrReceiver.printIRResultRawFormatted(&Serial, true);
    }
    if (IrReceiver.decodedIRData.protocol == NEC) {
      received = IrReceiver.decodedIRData.command;
      Serial.print("Command: 0x");
      Serial.println(received, HEX);
    }
    IrReceiver.resume();
  }
  return received;
}

void ledCode(uint16_t rCode) {
  switch (rCode) {
    case 0x68:   // Ausschalten
      Serial.println("Button aus");
      pixels.clear();
      pixels.show();
      break;
    case 0x30:   // Farbe Rot
      Serial.println("Farbe Rot");
      colorSwitch(pixels.Color(255, 0, 0));
      break;
    case 0x18:   // Farbe Grün
      Serial.println("Farbe Grün");
      colorSwitch(pixels.Color(0, 255, 0));
      break;
    case 0x52:
      Serial.println("Rainbow");
      rainbow();
      break;
  }
}

void colorSwitch(uint32_t color) {
  for (int i = 0; i < pixels.numPixels(); ++i) {   // For each pixel in pixels...
    pixels.setPixelColor(i, color);                //  Set pixel's color (in RAM)
  }
  pixels.show();
}

void rainbow() {
  for (long firstPixelHue = 0; firstPixelHue < 5 * 65536; firstPixelHue += 256) {
    pixels.rainbow(firstPixelHue);
    pixels.show();   // Update strip with new contents
  }
}

void fsm() {
  static State state {State::irRemote};
  static uint16_t irCode;

  switch (state) {
    case State::irRemote:
      irCode = irReceive();
      if (irCode) { state = State::checkCode; }
      break;
    case State::checkCode:
      ledCode(irCode);
      IrReceiver.resume();
      state = State::irRemote;
      break;
  }
}

void setup() {
  Serial.begin(115200);

  IrReceiver.begin(gc::irReceivePin);
  Serial.print(F("Ready to receive IR signals at pin "));
  Serial.println(gc::irReceivePin);
  pixels.begin();
  pixels.setBrightness(brightness);
  pixels.show();
}

void loop() { fsm(); }
Taste 0: Löschen Taste 1: rot Taste 2: grün Taste 9: rainbow