#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel ledstrip(16, 12, NEO_GRB + NEO_KHZ800);
unsigned long lastChange = 0;
uint8_t hue = 0;
uint8_t colorIndex = 0; // 0–15
const uint8_t colors[16][3] = {
{255, 0, 0}, // 1 Red
{255, 80, 0}, // 2 Orange
{255, 255, 0}, // 3 Yellow
{120, 255, 0}, // 4 Lime
{ 0, 255, 0}, // 5 Green
{ 0, 255, 120}, // 6 Spring green
{ 0, 255, 255}, // 7 Cyan
{ 0, 120, 255}, // 8 Sky blue
{ 0, 0, 255}, // 9 Blue
{ 80, 0, 255}, // 10 Violet
{150, 0, 255}, // 11 Purple
{255, 0, 255}, // 12 Magenta
{255, 0, 120}, // 13 Pink
{255, 60, 60}, // 14 Rose
{255, 200, 120}, // 15 Warm white
{180, 200, 255} // 16 Cool white
};
void setup() {
ledstrip.begin();
}
void wheel(uint8_t pos, uint8_t &r, uint8_t &g, uint8_t &b) {
if (pos < 85) {
r = 255 - pos * 3;
g = pos * 3;
b = 0;
} else if (pos < 170) {
pos -= 85;
r = 0;
g = 255 - pos * 3;
b = pos * 3;
} else {
pos -= 170;
r = pos * 3;
g = 0;
b = 255 - pos * 3;
}
}
void RAINBOW(int DELAY) {
uint8_t r, g, b;
wheel(hue, r, g, b);
ledstrip.setPixelColor(0, Colour(r, g, b));
ledstrip.show();
hue++;
delay(DELAY);
}
void loop() {
if (millis() - lastChange >= interval) {
lastChange = millis();
ledstrip.setPixelColor(
0,
Colour(
colors[colorIndex][0],
colors[colorIndex][1],
colors[colorIndex][2]
)
);
ledstrip.show();
colorIndex++;
if (colorIndex >= 16) {
colorIndex = 0; // back to 1
}
}
}