// Include library #include "RGBEncoder.h" // Create an RGBEncoder object RGBEncoder knob; int i = 0; // Handler of button void buttonHandler(bool pressed) { if (!pressed) return; if (i == 0) { knob.setColor(255, 0, 0); i++; } else if (i == 1) { knob.setColor(0, 255, 0); i++; } else if (i == 2) { knob.setColor(0, 0, 255); i++; } else if (i == 3) { knob.setColor(0, 0, 0); i = 0; } } void setup() { knob.begin(); // initialize // register handlers for button and encoder knob.onButton(buttonHandler); // switch-off led knob.setColor(0, 0, 0); } void loop() { knob.update(); // upkeep to trigger the handler when necessary }