Bright Lights, Christmas Nights

Bright Lights, Christmas Nights © CC BY

Why limit yourself to an angel on top of the tree when you can have an over sized Christmas ornament with 192 RGB LEDs blinking!

  • 2,814 views
  • 1 comment
  • 10 respects

Components and supplies

Necessary tools and machines

Apps and online services

About this project

During Halloween I decide to decorate our pumpkin a little differently this year. Using an Arduino and a bunch of RGB LEDs I turned in into a beacon welcoming the trick-or-treaters. After the pumpkin passed on, I decided that this ornament needed a more permanent 3d printed skeleton, and needed some new Christmas themed light patterns. The result is the flashy Christmas ornament that you see here.

https://www.youmagine.com/designs/bright-lights-christmas-nights

You can see it in action here:

Code

Arduino CodeArduino
Arduino code to run the LED show. This uses the very easy to use FastLED library http://fastled.io/.
#include <FastLED.h>
#define DATA_PIN 6
#define NUM_LEDS 192
CRGB leds[NUM_LEDS];

int vane;
int ring;
int ringdir;
int count;
int mode;
int splatx;
int splaty;
int splatd;
int colorstep;
unsigned long color;
int icelevel[12];
unsigned long fade[16]={0xffffff,0xbfbfbf,0x7f7f7f,0x5f5f5f,0x3f3f3f,0x2f2f2f,0x1f1f1f,0x171717,0x0f0f0f,0x0b0b0b,0x070707,0x050505,0x030303,0x020202,0x010101,0};
void setxy(int x, int y, CRGB c)
{
  if (x<0) x+=12;
  if (x>11) x-=12;
  if (y<0)
  {
    y=-y;
    x+=6;
    if (x>11) x-=12;
  }
  if (y>15)
  {
    y=31-y;
    x+=6;
    if (x>11) x-=12;
  }  
  leds[y+x*16]=c;
}

void nextcolor()
{
  if (colorstep==1)
  {
    color=0x00ff00;
    colorstep++;
  }
  else if (colorstep==2)
  {
    color=0xff0000;
    colorstep++;
  }
  else if (colorstep==3)
  {
    color=0x0000ff;
    colorstep=1;
  }
}

void newsplat()
{
  splatx = random(3,9);
  splaty = random(0,16);
  splatd=0;
}

void iceinit()
{
  int i;
  for (i=0;i<12;i++)
    icelevel[i]=random(0,20)-20;
}

void setup()
{
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  FastLED.clear();
  vane=0;
  ring=0;
  color=0x0000ff;
  mode=1;
  count=0;
  colorstep=1;
  ringdir=1;
  newsplat();
  iceinit();
}

void vanes()
{
  int v,i;
  if (vane>0)
  {
    v = (vane-1)<<4;
    for (i=0;i<16;i++)
      leds[v+i]=color&0x1f1f1f;
  }
  v = vane<<4;
  for (i=0;i<16;i++)
    leds[v+i]=color;
  vane++;
  if (vane==12)
  {
    vane=0;
    nextcolor();
  }
}

void rings()
{
  int i;
  for (i=0;i<12;i++)
    leds[i*16+ring]=color;
  ring+=ringdir;
  if (ring==15)
  {
    ringdir=-1;
  }
  if (ring==0)
  {
    ringdir=1;
    nextcolor();
  }
}

void splat()
{
  if (splatd==0)
  {
    setxy(splatx,splaty,color);
    splatd++;
  }
  else if (splatd==1)
  {
    setxy(splatx,splaty,color&0x7f7f7f);
    setxy(splatx+splatd,splaty,color);
    setxy(splatx-splatd,splaty,color);
    setxy(splatx,splaty+splatd,color);
    setxy(splatx,splaty-splatd,color);
    splatd++;
  }
  else if (splatd==2)
  {
    setxy(splatx,splaty,color&0x3f3f3f);
    setxy(splatx+1,splaty,color&0x7f7f7f);
    setxy(splatx-1,splaty,color&0x7f7f7f);
    setxy(splatx,splaty+1,color&0x7f7f7f);
    setxy(splatx,splaty-1,color&0x7f7f7f);
    setxy(splatx+splatd,splaty,color);
    setxy(splatx-splatd,splaty,color);
    setxy(splatx,splaty+splatd,color);
    setxy(splatx,splaty-splatd,color);
    splatd++;
  }
  else if (splatd==3)
  {
    setxy(splatx,splaty,color&0x1f1f1f);
    setxy(splatx+1,splaty,color&0x3f3f3f);
    setxy(splatx-1,splaty,color&0x3f3f3f);
    setxy(splatx,splaty+1,color&0x3f3f3f);
    setxy(splatx,splaty-1,color&0x3f3f3f);
    setxy(splatx+splatd,splaty,color&0x7f7f7f);
    setxy(splatx-splatd,splaty,color&0x7f7f7f);
    setxy(splatx,splaty+splatd,color&0x7f7f7f);
    setxy(splatx,splaty-splatd,color&0x7f7f7f);
    splatd++;
  }
  else if (splatd==4)
  {
    setxy(splatx,splaty,color&0x0f0f0f);
    setxy(splatx+1,splaty,color&0x1f1f1f);
    setxy(splatx-1,splaty,color&0x1f1f1f);
    setxy(splatx,splaty+1,color&0x1f1f1f);
    setxy(splatx,splaty-1,color&0x1f1f1f);
    setxy(splatx+splatd,splaty,color&0x3f3f3f);
    setxy(splatx-splatd,splaty,color&0x3f3f3f);
    setxy(splatx,splaty+splatd,color&0x3f3f3f);
    setxy(splatx,splaty-splatd,color&0x3f3f3f);
    splatd++;
  }
  else if (splatd==5)
  {
    setxy(splatx+1,splaty,color&0x0f0f0f);
    setxy(splatx-1,splaty,color&0x0f0f0f);
    setxy(splatx,splaty+1,color&0x0f0f0f);
    setxy(splatx,splaty-1,color&0x0f0f0f);
    setxy(splatx+splatd,splaty,color&0x1f1f1f);
    setxy(splatx-splatd,splaty,color&0x1f1f1f);
    setxy(splatx,splaty+splatd,color&0x1f1f1f);
    setxy(splatx,splaty-splatd,color&0x1f1f1f);
    splatd++;
  }
  else if (splatd==6)
  {
    setxy(splatx+splatd,splaty,color&0x0f0f0f);
    setxy(splatx-splatd,splaty,color&0x0f0f0f);
    setxy(splatx,splaty+splatd,color&0x0f0f0f);
    setxy(splatx,splaty-splatd,color&0x0f0f0f);
    splatd++;
  }
}

void ice()
{
  int i,j,k;
  FastLED.clear();
  for (i=0;i<12;i++)
  {
    if (icelevel[i]>-1)
    {
      k=0;
      for (j=icelevel[i];j>=0;j--)
      {
        if (j<16 && k<16)
          setxy(i,15-j,fade[k]);
        k++;
      }
    }
    icelevel[i]++;
    if (icelevel[i]==32)
      icelevel[i]=random(0,20)-20;
  }
  FastLED.show();
}

void loop()
{
  if (mode==1)
  {
    FastLED.clear();
    vanes();
    FastLED.show();
    count++;
    if (count==72)
    {
      count=0;
      mode++;
    }
    delay(100);
  }
  else if (mode==2)
  {
    FastLED.clear();
    rings();
    FastLED.show();
    count++;
    if (count==186)
    {
      count=0;
      mode=3;
    }
    delay(30);
  }
  else if (mode==3)
  {
    FastLED.clear();
    splat();
    FastLED.show();
    if (splatd==7)
    {
      newsplat();
      nextcolor();
      count++;
    }
    if (count==30)
    {
      count=0;
      mode=4;
      iceinit();
    }
    delay(50);
  }
  else if (mode==4)
  {
    ice();
    count++;
    if (count==500)
    {
      count=0;
      mode=1;
    }
    delay(100);
  }
}

Custom parts and enclosures

Zip file of STL parts for 3d print
mN3nEnzJuwsMKuZnV76q.zip

Schematics

Fritzing Schematic
bdlN9J7g0K2O7WjOhofo.fzz
KdLERFsHcalSfPnEeEM0.png
Kdlerfshcalsfpneeem0

Comments

Similar projects you might like

Christmas and More Lights

Project tutorial by Team FunguyPro

  • 1,695 views
  • 0 comments
  • 4 respects

Programmable Christmas Mason Jar Lights

Project tutorial by Katie Kristoff

  • 2,427 views
  • 0 comments
  • 16 respects

Huge LED Christmas Lights

Project showcase by Savva Osipov

  • 11,574 views
  • 2 comments
  • 34 respects

Sparkly Arduino Christmas Lights

Project tutorial by Donald Doerres

  • 10,132 views
  • 0 comments
  • 7 respects

How to Configure NeoPixels Using Vixen Lights and Arduino

Project tutorial by Victor Aguilar

  • 13,219 views
  • 23 comments
  • 28 respects

Christmas Tree with 150 Digital LED Pixels

Project tutorial by Martino Ghisleni

  • 4,775 views
  • 0 comments
  • 10 respects
Add projectSign up / Login