Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <Adafruit_NeoPixel.

h>

#define NUM_LEDS 7
#define DATA_PIN 27

Adafruit_NeoPixel pixels(NUM_LEDS, DATA_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
pixels.begin();
pixels.setBrightness(255); // Adjust brightness if necessary
fillVIBGYORColors();
}

void loop() {
// The colors will be displayed during setup, so no need to do anything in loop
}

void fillVIBGYORColors() {
// VIBGYOR colors: Violet, Indigo, Blue, Green, Yellow, Orange, Red
uint32_t colors[] = {pixels.Color(170, 170/2, 255), pixels.Color(170, 170/2,
255/2), pixels.Color(170, 170*3/4, 255*3/4),
pixels.Color(215, 112, 62), pixels.Color(215, 112/2, 62/2),
pixels.Color(215, 112/2, 62*3/4),
pixels.Color(215, 112, 62)};

int numColors = sizeof(colors) / sizeof(colors[0]);

for (int i = 0; i < NUM_LEDS; i++) {


int colorIndex = i * numColors / NUM_LEDS; // Distribute colors evenly across
LEDs
pixels.setPixelColor(i, colors[colorIndex]);
}

pixels.show();
}

You might also like