#include <Adafruit_NeoPixel.h> //include the neopixel library
#define PIN 6 //define the pin number for the neopixel ring
#define NUMPIXELS 16 //define the number of pixels in the ring
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); //create an instance of the neopixel object
void setup() {
pixels.begin(); //initialize the neopixel ring
}
void loop() {
//set all pixels to red
for (int i = 0; i < NUMPIXELS; i++) {
pixels.setPixelColor(i, pixels.Color(255, 0, 0)); //set the color of each pixel to red
pixels.show(); //update the neopixel ring
delay(1000); //wait for 100 milliseconds
}
//set all pixels to green
for (int i = 0; i < NUMPIXELS; i++) {
pixels.setPixelColor(i, pixels.Color(0, 255, 0)); //set the color of each pixel to green
pixels.show(); //update the neopixel ring
delay(100); //wait for 100 milliseconds
}
//set all pixels to blue
for (int i = 0; i < NUMPIXELS; i++) {
pixels.setPixelColor(i, pixels.Color(0, 0, 255)); //set the color of each pixel to blue
pixels.show(); //update the neopixel ring
delay(100); //wait for 100 milliseconds
pixels.clear();
}
}
//Code sourced from Adafruit NeoPixel library examples: https://github.com/adafruit/Adafruit_NeoPixel/blob/master/examples/strandtest/strandtest.ino