Christmas Star LED Neopixel Arduino Attigny85 Digispark

481

4

16

Introduction: Christmas Star LED Neopixel Arduino Attigny85 Digispark

About: I like to combine electronics like Arduino's, ESP8266 etc with 3D designing and 3D printing.

In this Instructable I show how I my a Christmas star using neopixels, driven by a Attigny digispark board, mounted on a 3D printed star

Step 1: Hardware

I glued the Neopixels (WS2812B) in parts on a 3D printed star and connected all the parts, pay attention to the direction of the data flow when connecting the parts.

The 3D designs are on my Thingiverse.

The GND en VCC (5V) is connected throughout the whole star, the data line is connected from the digispark module to line in.

The digispark module is mounted via hot glue, supported by tie wraps.

Add a top layer for diffusing the light.

Add a second top layer, separated by the separator items for more diffusing.

Step 2: Software

The program is on my Github.

See this instruction how to program a digispark board via the Arduino IDE:

https://digistump.com/wiki/digispark/tutorials/con...

In the program there are 13 patterns, which are randomly selected. The duration of the pattern is also randomly selected.

Most patterns run from the tips of the star. Since the the data in is connected to 3 neopixels from the tip, an offset in used.

Be the First to Share

    Recommendations

    • The 1000th Contest

      The 1000th Contest
    • Battery Powered Contest

      Battery Powered Contest
    • Hand Tools Only Challenge

      Hand Tools Only Challenge

    16 Discussions

    0
    jsmirnio99
    jsmirnio99

    Question 10 months ago

    This is great! I love the light patterns you've programmed. Is it possible to have the LEDs light from the center-outward as well as from the tip-inward?

    0
    Wim3d
    Wim3d

    Reply 10 months ago

    Thank you. If you have added patterns, I would like the code, so I can implement them in my star.

    0
    jsmirnio99
    jsmirnio99

    Reply 10 months ago

    Have you had a chance to try the new patterns?

    0
    Wim3d
    Wim3d

    Reply 10 months ago

    I received only the first part of the code. Can you send the part of the code with the new patterns?
    I plan to make a large star myself. I bought some WS2811 strands.

    0
    jsmirnio99
    jsmirnio99

    Reply 10 months ago

    Maybe the system cut it short. Here is its again:

    /*
    Sketch uses 9154 bytes (31%) of program storage space. Maximum is 28672 bytes.
    Global variables use 322 bytes (12%) of dynamic memory, leaving 2238 bytes for local variables. Maximum is 2560 bytes.
    */
    // Christmas star, neopixels, driven by Leonardo
    // written by W. Hoogervorst, december 2018/ Modified by JGS 2019
    #include <Adafruit_NeoPixel.h>
    #define PIN 6 // The pin on the Arduino connected to the NeoPixels
    #define BRIGHTNESS 50 // Set brightness (out of 256)
    #define NUMPIXELS 50 // Number of NeoPixels attached to the microcontroller
    #define SPOKES 5 // Equal parts for points of star or figure
    #define OFFSET 0 // Offset to start if not starting at pixel 0 as first LED
    #define RED 0xff0000
    #define GREEN 0x00ff00
    #define BLUE 0x0000ff
    #define OFF 0x000000
    Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_RGB + NEO_KHZ800);
    // RGB for PIXEL Strings; GRB for PIXEL strips
    uint32_t COLOR[] = {RED, GREEN, BLUE, RED, GREEN, BLUE};
    int delayval = 500; // delay for half a second
    long randNumber, randNumber2;
    void setup() {
    strip.begin(); // This initializes the NeoPixel library.
    strip.setBrightness(BRIGHTNESS);
    randomSeed(analogRead(0));
    RotateTips (4);
    FillFromCenter (6);
    RotateTips (4);
    colorsfromtip (4);
    }
    void loop()
    {
    randNumber = random(1, 16); // generate random number to select the pattern
    randNumber2 = random(2, 4); // generate random number to select the repetitions
    switch (randNumber)
    {
    case 1: changecolors(randNumber2); break;
    case 2: colorchase(randNumber2); break;
    case 3: colorsfromcenter(randNumber2); break;
    case 4: colorsfromtip2(randNumber2); break;
    case 5: colorsfromtip(randNumber2); break;
    case 6: colorstocenter(randNumber2); break;
    case 7: fadecolors(randNumber2); break;
    case 8: colorsfromtip2(randNumber2); break;
    case 9: rainbowCycle(10, randNumber2); break;
    case 10: blinkcolors(randNumber2); break;
    case 11: steadycolors(randNumber2); break;
    case 12: colorrun(randNumber2); break;
    case 13: colorfill(randNumber2); break;
    /* NEW PATTERNS November 2019 Smirniotopoulos */
    case 14: FillFromCenter (randNumber2); break;
    case 15: RotateTips (randNumber2); break;
    }
    }
    // rainbow cycle from adafruit example
    void rainbowCycle(uint8_t wait, int repeat) {
    uint16_t i, j;
    for (j = 0; j < 256 * repeat; j++) { // repeat cycles of all colors on wheel
    for (i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
    }
    }
    // Input a value 0 to 255 to get a color value.
    // The colours are a transition r - g - b - back to r.
    uint32_t Wheel(byte WheelPos) {
    WheelPos = 255 - WheelPos;
    if (WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
    } else if (WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
    } else {
    WheelPos -= 170;
    return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
    }
    }
    void colorsfromtip(int repeat)
    {
    for (int k = 0; k < repeat; k++)
    {
    for (int color = 0; color < 3; color++)
    {
    for (int i = 0; i < ((NUMPIXELS / SPOKES / 2) + 1); i++)
    {
    for (int j = 0; j < (SPOKES + 1); j++)
    {
    strip.setPixelColor(OFFSET + (j * (NUMPIXELS / SPOKES) + i), COLOR[color]);
    strip.setPixelColor((OFFSET + (j + 1) * (NUMPIXELS / SPOKES) - i), COLOR[color]);
    strip.show();
    }
    delay(delayval);
    }
    }
    }
    }
    void fadecolors(int repeat)
    {
    //fade in and out
    for (int j = 0; j < repeat; j++)
    {
    for (int color = 0; color < 3; color++)
    {
    for (int fade = 0; fade < BRIGHTNESS / 2; fade++)
    {
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setBrightness(fade * 2);
    strip.setPixelColor(i, COLOR[color]);
    strip.show();
    }
    delay(1);
    }
    for (int fade = BRIGHTNESS / 2; fade > 0; fade--)
    {
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setBrightness(fade * 2);
    strip.setPixelColor(i, COLOR[color]);
    strip.show();
    }
    delay(1);
    }
    }
    }
    strip.setBrightness(BRIGHTNESS);
    }
    void blinkcolors(int repeat) {
    for (int j = 0; j < repeat; j++)
    { for (int color = 0; color < 3; color++)
    {
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setPixelColor(i, COLOR[color]);
    strip.show();
    }
    delay(delayval);
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setPixelColor(i, OFF);
    strip.show();
    }
    delay(delayval);
    }
    }
    }
    void colorrun(int repeat)
    {
    for (int k = 0; k < repeat; k++)
    {
    for (int color = 0; color < 3; color++)
    {
    for (int i = 0; i < (NUMPIXELS / SPOKES); i++)
    {
    for (int j = 0; j < SPOKES + 1; j++)
    {
    strip.setPixelColor(OFFSET + (j * (NUMPIXELS / SPOKES) + i), COLOR[color]);
    }
    strip.show();
    delay(delayval / 2);
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setPixelColor(i, OFF);
    }
    strip.show();
    }
    }
    }
    }
    void colorfill(int repeat)
    {
    for (int k = 0; k < repeat; k++)
    {
    for (int color = 0; color < 3; color++)
    {
    for (int i = 0; i < (NUMPIXELS / SPOKES); i++)
    {
    for (int j = 0; j < SPOKES + 1; j++)
    {
    strip.setPixelColor(OFFSET + (j * (NUMPIXELS / SPOKES) + i), COLOR[color]);
    strip.show();
    }
    delay(delayval);
    }
    }
    }
    }
    void colorsfromtip2(int repeat)
    {
    for (int k = 0; k < repeat; k++)
    {
    for (int color = 0; color < 3; color++)
    {
    for (int i = 0; i < ((NUMPIXELS / SPOKES / 2) + 1); i++)
    {
    for (int j = 0; j < (SPOKES + 1); j++)
    {
    strip.setPixelColor(OFFSET + (j * (NUMPIXELS / SPOKES) + i), COLOR[color]);
    strip.setPixelColor((OFFSET + (j + 1) * (NUMPIXELS / SPOKES) - i), COLOR[color]);
    strip.show();
    }
    delay(delayval);
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setPixelColor(i, OFF);
    strip.show();
    }
    }
    }
    }
    }
    void colorsfromtip3(int repeat)
    {
    for (int k = 0; k < repeat; k++)
    {
    for (int i = 0; i < ((NUMPIXELS / SPOKES / 2) + 1); i++)
    {
    for (int j = 0; j < (SPOKES + 1); j++)
    {
    strip.setPixelColor(OFFSET + (j * (NUMPIXELS / SPOKES) + i), COLOR[i]);
    strip.setPixelColor((OFFSET + (j + 1) * (NUMPIXELS / SPOKES) - i), COLOR[i]);
    strip.show();
    }
    delay(delayval);
    }
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setPixelColor(i, OFF);
    strip.show();
    }
    delay(delayval);
    }
    }
    void steadycolors(int repeat)
    {
    for (int i = 0; i < ((NUMPIXELS / SPOKES / 2) + 1); i++)
    {
    for (int j = 0; j < (SPOKES + 1); j++)
    {
    strip.setPixelColor(OFFSET + (j * (NUMPIXELS / SPOKES) + i), COLOR[i]);
    strip.setPixelColor((OFFSET + (j + 1) * (NUMPIXELS / SPOKES) - i), COLOR[i]);
    strip.show();
    }
    }
    delay(delayval * repeat);
    }
    void colorchase(int repeat)
    {
    for (int m = 0; m < repeat; m++) {
    for (int k = 0; k < 3; k++)
    {
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setPixelColor(i, COLOR[k]);
    strip.show();
    delay(delayval / 10);
    }
    }
    }
    }
    void changecolors(int repeat)
    {
    for (int m = 0; m < repeat; m++) {
    for (int k = 0; k < 3; k++)
    {
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setPixelColor(i, COLOR[k]);
    }
    strip.show();
    delay(delayval);
    }
    }
    }
    void colorstocenter(int repeat)
    {
    for (int m = 0; m < repeat; m++) {
    for (int k = 3; k > 0; k--)
    {
    for (int i = 3; i >= 0; i--)
    {
    for (int j = 0; j < (SPOKES + 1); j++)
    {
    strip.setPixelColor(OFFSET + (j * (NUMPIXELS / SPOKES) + i), COLOR[k + i]);
    strip.setPixelColor((OFFSET + (j + 1) * (NUMPIXELS / SPOKES) - i), COLOR[k + i]);
    }
    }
    strip.show();
    delay(delayval);
    }
    }
    }
    void colorsfromcenter(int repeat)
    {
    for (int m = 0; m < repeat; m++) {
    for (int k = 0; k < 3; k++)
    {
    for (int i = 0; i < ((NUMPIXELS / SPOKES / 2) + 1); i++)
    {
    for (int j = 0; j < (SPOKES + 1); j++)
    {
    strip.setPixelColor(OFFSET + (j * (NUMPIXELS / SPOKES) + i), COLOR[k + i]);
    strip.setPixelColor((OFFSET + (j + 1) * (NUMPIXELS / SPOKES) - i), COLOR[k + i]);
    strip.show();
    }
    }
    delay(delayval);
    }
    }
    }
    // Fill the dots one after the other with a color
    void colorWipe(uint32_t c, uint8_t wait) {
    for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
    }
    }
    /* NEW PATTERNS November 2019 Smirniotopoulos */
    /*
    int TIP1 [] = {45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5};
    int TIP2 [] = {5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
    int TIP3 [] = {15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25};
    int TIP4 [] = {25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35};
    int TIP5 [] = {35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45};
    */
    /* Build Matrix for Spokes */
    const int rows = SPOKES;
    const int cols = (NUMPIXELS / SPOKES) + 1;
    int TIP[rows][cols] = {
    {45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5},
    {5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
    {15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25},
    {25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35},
    {35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45}
    };
    void RotateTips(int repeat) {
    strip.Color(125, 125, 125); // RESET to Background Color
    delay (2000);
    // Number of Times for a Complete Rotation
    for (int r = 0; r < repeat; r++) { // Current Cycle Number
    for (int color = 0; color < 3; color++) {
    for (int j = 0; j < SPOKES; j++) { // Current Spoke Number
    for (int PIX = 0; PIX < 11; PIX++) { // Current Pixel Number
    strip.setPixelColor(TIP[j][PIX], COLOR [color] );
    }
    strip.show();
    delay(200);
    colorWipe(strip.Color(0, 0, 0), 1); // Black
    }
    }
    }
    }
    void FillFromCenter(int repeat) {
    for (int r = 0; r < repeat; r++) { // Increment Cycle Number
    for (int color = 0; color < 3; color++) {
    for (int i = 0; i < (NUMPIXELS / SPOKES / 2) + 1; i++) { // Increment Pixel Number
    for (int spoke = 0; spoke < SPOKES; spoke ++) { // Increment Spoke Number
    int PIX1 = (spoke * (NUMPIXELS / SPOKES)) + (NUMPIXELS / SPOKES / 2) - i ; //
    strip.setPixelColor(PIX1, COLOR [color]);
    int PIX2 = (spoke * (NUMPIXELS / SPOKES)) + (NUMPIXELS / SPOKES / 2) + i ; //
    strip.setPixelColor(PIX2, COLOR [color]);
    }
    strip.show();
    delay(500);
    /* Illuminate One Ring at a Time from the Center */
    // colorWipe(strip.Color(0, 0, 0), 1); // Black All Pixels
    }
    /* Fill Each Spoke from the Center */
    colorWipe(strip.Color(0, 0, 0), 1); // Black All Pixels
    }
    }
    }

    0
    jsmirnio99
    jsmirnio99

    Reply 10 months ago

    Great patterns! Thanks for sharing!

    0
    Wim3d
    Wim3d

    Reply 10 months ago

    Thanks, I will first build my 50 LED star and then will try your patterns and maybe make some more myself.

    0
    VictorSvetogor
    VictorSvetogor

    Reply 10 months ago

    Hi, nice work !
    how 50 LEDs are placed on the star?

    0
    jsmirnio99
    jsmirnio99

    10 months ago

    I updated my star patterns: shortened the length of candy cane stripe to 4 pixels (looks better); and, added Sparkle pattern.

    /*
    Sketch uses 9670 bytes (33%) of program storage space. Maximum is 28672 bytes.
    Global variables use 322 bytes (12%) of dynamic memory, leaving 2238 bytes for local variables. Maximum is 2560 bytes.
    */
    // Christmas star, Neopixels, driven by Leonardo
    // written by W. Hoogervorst, december 2018/ Modified by JGS 2019
    #include <Adafruit_NeoPixel.h>
    #define LED 13 // Pin for LED (for debugging)
    #define PIN 6 // The pin on the Arduino connected to the NeoPixels
    #define BRIGHTNESS 50 // Set brightness (out of 256)
    #define NUMPIXELS 50 // Number of NeoPixels attached to the microcontroller
    #define SPOKES 5 // Equal parts for points of star or figure
    #define OFFSET 0 // Offset to start if not starting at pixel 0 as first LED
    #define RED 0xff0000
    #define GREEN 0x00ff00
    #define BLUE 0x0000ff
    #define OFF 0x000000
    #define WHITE 0xffffff
    Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_RGB + NEO_KHZ800);
    // RGB for PIXEL Strings; GRB for PIXEL strips
    uint32_t COLOR[] = {RED, GREEN, BLUE, RED, GREEN, BLUE};
    int delayval = 500; // delay for half a second
    long randNumber, randNumber2;
    void setup() {
    pinMode(LED, OUTPUT);
    strip.begin(); // This initializes the NeoPixel library.
    strip.setBrightness(BRIGHTNESS);
    randomSeed(analogRead(0));
    Sparkle(0xff, 0xff, 0xff, 50);
    CandyCane (2, 4, 100); // Red and White Moving Stipes
    RotateTips (4); // Illuminate 1 Spoke at a time
    FillFromCenter (6); // Fill with Color from the Center
    colorsfromtip (4); // Overlaps New Colors onto Previous (Nice!)
    }
    void loop()
    {
    randNumber = random(1, 18); // generate random number to select the pattern
    randNumber2 = random(2, 4); // generate random number to select the repetitions
    switch (randNumber)
    {
    case 1: changecolors(randNumber2); break;
    case 2: colorchase(randNumber2); break;
    case 3: colorsfromcenter(randNumber2); break;
    case 4: colorsfromtip2(randNumber2); break;
    case 5: colorsfromtip(randNumber2); break;
    case 6: colorstocenter(randNumber2); break;
    case 7: fadecolors(randNumber2); break;
    case 8: colorsfromtip2(randNumber2); break;
    case 9: rainbowCycle(10, randNumber2); break;
    case 10: blinkcolors(randNumber2); break;
    case 11: steadycolors(randNumber2); break;
    case 12: colorrun(randNumber2); break;
    case 13: colorfill(randNumber2); break;
    /* NEW PATTERNS November 2019 Smirniotopoulos */
    case 14: FillFromCenter (randNumber2); break;
    case 15: RotateTips (randNumber2); break;
    case 16: CandyCane (randNumber2, 4, 100); break;
    case 17: Sparkle(0xff, 0xff, 0xff, 50); break;
    }
    }
    // rainbow cycle from adafruit example
    void rainbowCycle(uint8_t wait, int repeat) {
    uint16_t i, j;
    for (j = 0; j < 256 * repeat; j++) { // repeat cycles of all colors on wheel
    for (i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
    }
    }
    // Input a value 0 to 255 to get a color value.
    // The colours are a transition r - g - b - back to r.
    uint32_t Wheel(byte WheelPos) {
    WheelPos = 255 - WheelPos;
    if (WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
    } else if (WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
    } else {
    WheelPos -= 170;
    return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
    }
    }
    void colorsfromtip(int repeat)
    {
    for (int k = 0; k < repeat; k++)
    {
    for (int color = 0; color < 3; color++)
    {
    for (int i = 0; i < ((NUMPIXELS / SPOKES / 2) + 1); i++)
    {
    for (int j = 0; j < (SPOKES + 1); j++)
    {
    strip.setPixelColor(OFFSET + (j * (NUMPIXELS / SPOKES) + i), COLOR[color]);
    strip.setPixelColor((OFFSET + (j + 1) * (NUMPIXELS / SPOKES) - i), COLOR[color]);
    strip.show();
    }
    delay(delayval);
    }
    }
    }
    }
    void fadecolors(int repeat)
    {
    //fade in and out
    for (int j = 0; j < repeat; j++)
    {
    for (int color = 0; color < 3; color++)
    {
    for (int fade = 0; fade < BRIGHTNESS / 2; fade++)
    {
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setBrightness(fade * 2);
    strip.setPixelColor(i, COLOR[color]);
    strip.show();
    }
    delay(1);
    }
    for (int fade = BRIGHTNESS / 2; fade > 0; fade--)
    {
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setBrightness(fade * 2);
    strip.setPixelColor(i, COLOR[color]);
    strip.show();
    }
    delay(1);
    }
    }
    }
    strip.setBrightness(BRIGHTNESS);
    }
    void blinkcolors(int repeat) {
    for (int j = 0; j < repeat; j++)
    { for (int color = 0; color < 3; color++)
    {
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setPixelColor(i, COLOR[color]);
    strip.show();
    }
    delay(delayval);
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setPixelColor(i, OFF);
    strip.show();
    }
    delay(delayval);
    }
    }
    }
    void colorrun(int repeat)
    {
    for (int k = 0; k < repeat; k++)
    {
    for (int color = 0; color < 3; color++)
    {
    for (int i = 0; i < (NUMPIXELS / SPOKES); i++)
    {
    for (int j = 0; j < SPOKES + 1; j++)
    {
    strip.setPixelColor(OFFSET + (j * (NUMPIXELS / SPOKES) + i), COLOR[color]);
    }
    strip.show();
    delay(delayval / 2);
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setPixelColor(i, OFF);
    }
    strip.show();
    }
    }
    }
    }
    void colorfill(int repeat)
    {
    for (int k = 0; k < repeat; k++)
    {
    for (int color = 0; color < 3; color++)
    {
    for (int i = 0; i < (NUMPIXELS / SPOKES); i++)
    {
    for (int j = 0; j < SPOKES + 1; j++)
    {
    strip.setPixelColor(OFFSET + (j * (NUMPIXELS / SPOKES) + i), COLOR[color]);
    strip.show();
    }
    delay(delayval);
    }
    }
    }
    }
    void colorsfromtip2(int repeat)
    {
    for (int k = 0; k < repeat; k++)
    {
    for (int color = 0; color < 3; color++)
    {
    for (int i = 0; i < ((NUMPIXELS / SPOKES / 2) + 1); i++)
    {
    for (int j = 0; j < (SPOKES + 1); j++)
    {
    strip.setPixelColor(OFFSET + (j * (NUMPIXELS / SPOKES) + i), COLOR[color]);
    strip.setPixelColor((OFFSET + (j + 1) * (NUMPIXELS / SPOKES) - i), COLOR[color]);
    strip.show();
    }
    delay(delayval);
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setPixelColor(i, OFF);
    strip.show();
    }
    }
    }
    }
    }
    void colorsfromtip3(int repeat)
    {
    for (int k = 0; k < repeat; k++)
    {
    for (int i = 0; i < ((NUMPIXELS / SPOKES / 2) + 1); i++)
    {
    for (int j = 0; j < (SPOKES + 1); j++)
    {
    strip.setPixelColor(OFFSET + (j * (NUMPIXELS / SPOKES) + i), COLOR[i]);
    strip.setPixelColor((OFFSET + (j + 1) * (NUMPIXELS / SPOKES) - i), COLOR[i]);
    strip.show();
    }
    delay(delayval);
    }
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setPixelColor(i, OFF);
    strip.show();
    }
    delay(delayval);
    }
    }
    void steadycolors(int repeat)
    {
    for (int i = 0; i < ((NUMPIXELS / SPOKES / 2) + 1); i++)
    {
    for (int j = 0; j < (SPOKES + 1); j++)
    {
    strip.setPixelColor(OFFSET + (j * (NUMPIXELS / SPOKES) + i), COLOR[i]);
    strip.setPixelColor((OFFSET + (j + 1) * (NUMPIXELS / SPOKES) - i), COLOR[i]);
    strip.show();
    }
    }
    delay(delayval * repeat);
    }
    void colorchase(int repeat)
    {
    for (int m = 0; m < repeat; m++) {
    for (int k = 0; k < 3; k++)
    {
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setPixelColor(i, COLOR[k]);
    strip.show();
    delay(delayval / 10);
    }
    }
    }
    }
    void changecolors(int repeat)
    {
    for (int m = 0; m < repeat; m++) {
    for (int k = 0; k < 3; k++)
    {
    for (int i = 0; i < NUMPIXELS; i++)
    {
    strip.setPixelColor(i, COLOR[k]);
    }
    strip.show();
    delay(delayval);
    }
    }
    }
    void colorstocenter(int repeat)
    {
    for (int m = 0; m < repeat; m++) {
    for (int k = 3; k > 0; k--)
    {
    for (int i = 3; i >= 0; i--)
    {
    for (int j = 0; j < (SPOKES + 1); j++)
    {
    strip.setPixelColor(OFFSET + (j * (NUMPIXELS / SPOKES) + i), COLOR[k + i]);
    strip.setPixelColor((OFFSET + (j + 1) * (NUMPIXELS / SPOKES) - i), COLOR[k + i]);
    }
    }
    strip.show();
    delay(delayval);
    }
    }
    }
    void colorsfromcenter(int repeat)
    {
    for (int m = 0; m < repeat; m++) {
    for (int k = 0; k < 3; k++)
    {
    for (int i = 0; i < ((NUMPIXELS / SPOKES / 2) + 1); i++)
    {
    for (int j = 0; j < (SPOKES + 1); j++)
    {
    strip.setPixelColor(OFFSET + (j * (NUMPIXELS / SPOKES) + i), COLOR[k + i]);
    strip.setPixelColor((OFFSET + (j + 1) * (NUMPIXELS / SPOKES) - i), COLOR[k + i]);
    strip.show();
    }
    }
    delay(delayval);
    }
    }
    }
    // Fill the dots one after the other with a color
    void colorWipe(uint32_t c, uint8_t wait) {
    for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
    }
    }
    /* NEW PATTERNS November 2019 Smirniotopoulos */
    /*
    int TIP1 [] = {45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5};
    int TIP2 [] = {5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
    int TIP3 [] = {15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25};
    int TIP4 [] = {25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35};
    int TIP5 [] = {35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45};
    */
    /* Build Matrix for Spokes */
    const int rows = SPOKES;
    const int cols = (NUMPIXELS / SPOKES) + 1;
    int TIP[rows][cols] = {
    {45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5},
    {5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
    {15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25},
    {25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35},
    {35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45}
    };
    void RotateTips(int repeat) {
    strip.Color(125, 125, 125); // RESET to Background Color
    delay (2000);
    // Number of Times for a Complete Rotation
    for (int r = 0; r < repeat; r++) { // Current Cycle Number
    for (int color = 0; color < 3; color++) {
    for (int j = 0; j < SPOKES; j++) { // Current Spoke Number
    for (int PIX = 0; PIX < 11; PIX++) { // Current Pixel Number
    strip.setPixelColor(TIP[j][PIX], COLOR [color] );
    }
    strip.show();
    delay(200);
    colorWipe(strip.Color(0, 0, 0), 1); // Black
    }
    }
    }
    }
    void FillFromCenter(int repeat) {
    for (int r = 0; r < repeat; r++) { // Increment Cycle Number
    for (int color = 0; color < 3; color++) { // Change Colors
    for (int i = 0; i < (NUMPIXELS / SPOKES / 2) + 1; i++) { // Increment Pixel Ring Number
    for (int spoke = 0; spoke < SPOKES; spoke ++) { // Increment Spoke Number
    int PIX1 = (spoke * (NUMPIXELS / SPOKES)) + (NUMPIXELS / SPOKES / 2) - i ; //
    strip.setPixelColor(PIX1, COLOR [color]);
    int PIX2 = (spoke * (NUMPIXELS / SPOKES)) + (NUMPIXELS / SPOKES / 2) + i ; //
    strip.setPixelColor(PIX2, COLOR [color]);
    }
    strip.show();
    delay(500);
    /* Illuminate One Ring at a Time from the Center */
    // colorWipe(strip.Color(0, 0, 0), 1); // Black All Pixels
    }
    /* Fill Each Spoke from the Center */
    colorWipe(strip.Color(0, 0, 0), 1); // Black All Pixels
    }
    }
    }
    // Sparkle Pattern - Eiffel Tower Flashing Type
    void Sparkle(byte red, byte green, byte blue, int SpeedDelay) {
    colorWipe(strip.Color(125, 0, 0), 1); // Set RED Background Color for All Pixels
    for (int i = 0; i < (4 * NUMPIXELS); i++) { // Flashing Loop
    int Pixel = random(0, NUMPIXELS + 1);
    strip.setPixelColor (Pixel, WHITE);
    strip.show();
    digitalWrite(LED, HIGH);
    delay(SpeedDelay); // Duration of Each Flash
    strip.setPixelColor (Pixel, 125, 0, 0); // Reset Pixel to RED Background Color
    digitalWrite(LED, LOW);
    }
    colorWipe(strip.Color(125, 0, 125), 1); // Set All Pixels to Purple
    delay (2000);
    }
    /* CandyCane CHASING COLOR STRIPES
    // Create scrolling RED & WHITE - candy cane - stripes.
    // Try adjusting the width in pixels for various results.
    // Value "sets" should evenly divide into strand length
    // EXAMPLE USAGE: CandyCane(30,8,50); //30 sets, 8 pixels wide, 50us delay
    */
    void CandyCane (int sets, int width, int wait) {
    int PIX;
    sets = sets * NUMPIXELS;
    for (int j = 0; j < (sets * width); j++) {
    for (int i = 0; i < strip.numPixels(); i++) {
    PIX = strip.numPixels() - i - 1;
    if ( ((i + j) % (width * 2) ) < width)
    strip.setPixelColor(PIX, RED); // SET COLOR TO RED
    else
    strip.setPixelColor(PIX, WHITE); // SET COLOR TO WHITE
    };
    strip.show();
    delay(wait); // DELAY BETWEEN FRAMES (speed of moving stripe)
    };
    };

    0
    Wim3d
    Wim3d

    Reply 10 months ago

    Nice new pattern and great programming

    0
    jsmirnio99
    jsmirnio99

    10 months ago

    I see you were able to program rotatetips without using a matrix - Great! I'm going to try it out today. Thanks!

    0
    Wim3d
    Wim3d

    Reply 10 months ago

    I improved the code some more. https://github.com/Wim3d/Christmas_star/blob/master/Christmas_star_v2.ino
    I made a correction for an offset and for 'your' rotatetips I changed to the Adafruit 'fill' function, which simplifies the code.
    I added the 'rotatetipscolors' function in which the rotating tips have a different color.
    And I added the 'rotate5colors' function, which is my favorite. In this function 5 colors chase through the star.
    Also the blue color was improved and I corected for the right RGB strip instead of GRB.

    0
    jsmirnio99
    jsmirnio99

    Reply 10 months ago

    Thanks so much! Dankuwel