// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library
// revamped to have it look much like a Christmas wreath by Scott Milliken (2017)
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN 6
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 60
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN);
int myPixels[] = {5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60};
int delayval1 = 100; // delay for a 1/10th of a second
int delayval2 = 5000; // delay for 5 seconds
void setup() {
pixels.begin();
pixels.show(); // This initializes the NeoPixel library.
}
void loop() {
// For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
for(int i = 0; i < NUMPIXELS; i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(255,0,0)); // Moderately bright green color.
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval1); // Delay for a period of time (in milliseconds).
}
for(int i = NUMPIXELS-1; i >= 0; i--){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval1);
}
// Making every 5th LED Red to form Holly on the wreath, rest of the wreath stays green.
for (int i = 0; i < pixels.numPixels(); i += 5){
pixels.setPixelColor(i, 255, 0, 0);
pixels.show();
}
delay(delayval2);//pause for 5 seconds
// make the holly berry turn blue and back to red repeat twice then back to the start.
for(uint16_t pos = 0; pos < 12; pos++) {
pixels.setPixelColor(myPixels[pos], 0, 0, 255);
pixels.show();
delay(delayval1);
}
for(uint16_t pos = 0; pos < 12; pos++) {
pixels.setPixelColor(myPixels[pos], 255, 0, 0);
pixels.show();
delay(delayval1);
}
for(uint16_t pos = 0; pos < 12; pos++) {
pixels.setPixelColor(myPixels[pos], 0, 0, 255);
pixels.show();
delay(delayval1);
}
for(uint16_t pos = 0; pos < 12; pos++) {
pixels.setPixelColor(myPixels[pos], 255, 0, 0);
pixels.show();
delay(delayval1);
}
delay(delayval2);
}
Comments