// ##############################################################
// Neopixel WS2812 LED Interface #
// ##############################################################
//
// Neopixel WS2812 LED interface with Arduino Uno (Hardware & Simulation)
//
// Check out the link for Code explanation and Hardware details
// Link:
// http://tech.arunkumarn.in/blogs/arduino-uno/interfacing-neopixel-rgb-led-with-arduino-uno/
//
//
#include <Adafruit_NeoPixel.h>
#define LED_PIN 6
#define NUM_LEDS 16
Adafruit_NeoPixel pixels(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);
// Define the colors (R, G, B)
uint8_t colors[][3] = {
{255, 0, 0}, // Red
{0, 255, 0}, // Green
{0, 0, 255}, // Blue
{255, 169, 0}, // Orange
{255, 255, 255} // White
};
const int numColors = sizeof(colors) / sizeof(colors[0]);
void setup() {
pixels.begin();
}
void loop() {
// Display Yellow first
for (int i = 0; i < NUM_LEDS; i++) {
pixels.setPixelColor(i, pixels.Color(255, 255, 0));
}
pixels.show();
delay(2000);
// Cycle through colors
for (int c = 0; c < numColors; c++) {
for (int i = 0; i < NUM_LEDS; i++) {
pixels.setPixelColor(i, pixels.Color(colors[c][0], colors[c][1], colors[c][2]));
delay(50);
pixels.show();
}
pixels.show();
delay(1000);
}
}