Create your own Arduino Controlled LED Strip Holiday Lighting and Rival Griswold This Christmas

 

Is your house on fire, Clark?

 

Let’s be honest, with the prices dropping so steadily on LED strip lighting, the ability to be able to set-up your own fun holiday lighting is getting more feasible every day. The Arduino UNO board makes for a pretty excellent DIY lighting controller.

For this year’s holiday project, we’re using some digital RGB strips with a super simple Arduino control setup so that we can rival Clark Griswald ourselves. The difference between Analog and Digitally controlled led’s is the ability to control LEDs individually, with an analog rig, we can control the entirety of the strip. Digital LED’s are more expensive yet allow you to control the lights individually, so for this, we’re using Digital LEDs.

Christmas Lights and Holiday Lights

Required Parts:

1.) Arduino Uno Board ( You can use any Arduino board for this particular project. )

2.) Waterproof LED Strips ( Recommended: ws2801 from adafruit )

3.) Arduino Prototyping shield

4.) You will need (6) N-Channel Power MOSFET transistors

5.) 12V Power Supply and Connector ( under 6 amps will be fine. )

6.) 2 LED Connectors

7.) 2 male-to-male adapters ( if needed )

Christmas LED Holiday Lights

The Hardware:

If you’re unfamiliar with Arduino, you will need to upload a sketch which contains your light controller code using a USB drive.

1.) Prior to uploading your code, select the correct items from the Tools > Board and Tools > Port menus. The boards are described below. On the Mac, the serial port is probably something like /dev/tty.usbmodem241

2.) Once you’ve selected the correct serial port and board, press the upload button in the toolbar or select the Upload item from the Sketch menu. Current Arduino boards will reset automatically and begin the upload.

3.) On most boards, you’ll see the RX and TX LEDs blink as the sketch is being uploaded. The Arduino Software (IDE) will display a message when the upload is complete, or show an error.

4.) When you upload a sketch, you’re using the Arduino’s bootloader, a small program that’s loaded on the microcontroller on your board. It allows you to upload code without using any additional hardware. The bootloader is active for a few seconds when the board resets; then it starts whichever sketch was most recently uploaded to the microcontroller. The bootloader will blink the onboard (pin 13) LED when it starts (i.e. when the board resets).

The Result:

Required Code:

#include “SPI.h”
#include “Adafruit_WS2801.h”/*****************************************************************************
Example sketch for driving Adafruit WS2801 pixels!
Look up hex color values here:
http://cloford.com/resources/colours/500col.htm
This project is for this Adafruit product:
75mm Bar shape    —-> http://www.adafruit.com/products/1548
Adafruit also has:
12mm Bullet shape —-> https://www.adafruit.com/products/322
12mm Flat shape   —-> https://www.adafruit.com/products/738
36mm Square shape —-> https://www.adafruit.com/products/683
75mm Bar shape    —-> http://www.adafruit.com/products/1548
These pixels use SPI to transmit the color data, and have built in
high speed PWM drivers for 24 bit color per pixel
2 pins plus ground are required to interface
Adafruit credit for the base code:
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
*****************************************************************************/// Choose which 2 pins you will use for output.
// Can be any valid output pins.
// The colors of the wires may be totally different so
// BE SURE TO CHECK YOUR PIXELS TO SEE WHICH WIRES TO USE!
uint8_t dataPin  = 2;    // Yellow wire on Adafruit Pixels
uint8_t clockPin = 3;    // Green wire on Adafruit Pixels
uint16_t pixelCount = 21;
uint32_t rainbowList[] = {0xDC143C, // red
0xFFA500, // orange
0xFFFF00, // yellow
0x00FF00, // green
0x7D9EC0, // blue
0x4B0082, // indigo
0x9400D3  // violet
};// Don’t forget to connect the ground wire to Arduino ground,
// and the +5V wire to a +5V supply// Set the first variable to the NUMBER of pixels. 21 = 21 pixels in a row for 1548 bars
Adafruit_WS2801 strip = Adafruit_WS2801(pixelCount, dataPin, clockPin);// Optional: leave off pin numbers to use hardware SPI
// (pinout is then specific to each board and can’t be changed)
//Adafruit_WS2801 strip = Adafruit_WS2801(25);// For 36mm LED pixels: these pixels internally represent color in a
// different format.  Either of the above constructors can accept an
// optional extra parameter: WS2801_RGB is ‘conventional’ RGB order
// WS2801_GRB is the GRB order required by the 36mm pixels.  Other
// than this parameter, your code does not need to do anything different;
// the library will handle the format change.  Examples:
//Adafruit_WS2801 strip = Adafruit_WS2801(25, dataPin, clockPin, WS2801_GRB);
//Adafruit_WS2801 strip = Adafruit_WS2801(25, WS2801_GRB);void setup() {

/* A way to get a random seed is to read an un-attached A to D port
Value read is different each time you read it
*/
randomSeed(analogRead(0));

strip.begin();

// Update LED contents, to start they are all ‘off’
strip.show();
}

void loop() {
// Some example procedures showing how to display to the pixels
int i, row;
blank();
strip.show();
delay(5000);

colorWipe(Color(10, 0, 0), 1000);  // dim red

colorWipe(Color(0, 10, 0), 150);   // dim green

colorWipe(Color(0, 0, 10), 150);   // dim blue

colorWipe(Color(10, 10, 10), 150); // dim white

colorWipe(Color(15, 15, 0), 150);  // dim yellow

for (row = 0; row < 7; row++) {
for( i = 0; i < pixelCount; i++) {
blank();
strip.setPixelColor(i, rainbowList[row]);
strip.show();
delay(200);
}
}

for(i = 0; i < pixelCount; i++) {
blank(0x001000);
strip.setPixelColor(i, 10, 0, 0);
strip.show();
delay(100);
}

for(i = 0; i < pixelCount; i++) {
blank(0x100000);
strip.setPixelColor(i, 0, 10, 0);
strip.show();
delay(100);
}

for(i = 0; i < pixelCount; i++) {
blank();
strip.setPixelColor(i, 10, 0, 0);
strip.show();
delay(100);
}

for(i = (pixelCount-1); i>=0; i–) {
blank();
strip.setPixelColor(i, 0, 10, 0);
strip.show();
delay(100);
}

for(i = 0; i < pixelCount; i++) {
blank();
strip.setPixelColor(i, 0, 0, 10);
strip.show();
delay(100);
}

for(i = (pixelCount-1); i>=0; i–) {
blank();
strip.setPixelColor(i, 0, 10, 10);
strip.show();
delay(100);
}

for(i = 0; i < pixelCount; i++) {
blank();
strip.setPixelColor(i, 10, 0, 10);
strip.show();
delay(100);
}

for(i = (pixelCount-1); i>=0; i–) {
blank();
strip.setPixelColor(i, 15, 15, 0);
strip.show();
delay(100);
}

for(i = 0; i < pixelCount; i++) {
blank();
strip.setPixelColor(i, 0, 10, 0);
if(i > 0) {
strip.setPixelColor(i-1, 10, 0, 0);
strip.show();
}
delay(100);
}

int j;
for (j = 0; j < 10; j++) {
for(i = 0; i < pixelCount; i++) {
blank();
strip.setPixelColor(i, 0, 10, 0);
strip.setPixelColor(pixelCount-(i+1), 10, 0, 0);
strip.show();

delay(100);
}}

for (j = 0; j < 16; j++) {
for(i = 0; i < pixelCount; i++) {
blank();
strip.setPixelColor(i, 0, 10, 0);
strip.setPixelColor(pixelCount-(i+1), 10, 0, 0);
if( (i+10) < pixelCount) {
strip.setPixelColor(i+10, 0, 0, 10);
}
else {
strip.setPixelColor( (pixelCount – i – 10+3), 0, 0, 10);
}

strip.show();
delay(100);
}}
long rand1 = 0;
long rand2 = 0;

for (i = 0; i < 1000; i++) {
rand1 = random(0, 21);
rand2 = random(10, 0x00ffffff);
blank();
strip.setPixelColor( rand1, rand2);
strip.show();
delay(25);

}

rainbow(130);
rainbowCycle(120);
}

void blank(void) {
int i;
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, 0, 0, 0);
// strip.show();
}
}

void blank(uint32_t background) {
int i;
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, background);
//strip.show();
}
}

void rainbow(uint8_t wait) {
int i, j;

for (j=0; j < 256; j++) {     // 3 cycles of all 256 colors in the wheel
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel( (i + j) % 255));
}
strip.show();   // write all the pixels out
delay(wait);
}

}

// Slightly different, this one makes the rainbow wheel equally distributed
// along the chain
void rainbowCycle(uint8_t wait) {
int i, j;

for (j=0; j < 256 * 5; j++) {     // 5 cycles of all 25 colors in the wheel
for (i=0; i < strip.numPixels(); i++) {
// tricky math! we use each pixel as a fraction of the full 96-color wheel
// (thats the i / strip.numPixels() part)
// Then add in j which makes the colors go around per pixel
// the % 96 is to make the wheel cycle around
strip.setPixelColor(i, Wheel( ((i * 256 / strip.numPixels()) + j) % 256) );
}
strip.show();   // write all the pixels out
delay(wait);
}
}

// fill the dots one after the other with said color
// good for testing purposes
void colorWipe(uint32_t c, uint8_t wait) {
int i;

for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}

/* Helper functions */

// Create a 24 bit color value from R,G,B
uint32_t Color(byte r, byte g, byte b)
{
uint32_t c;
c = r;
c <<= 8;
c |= g;
c <<= 8;
c |= b;
return c;
}

//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)
{
if (WheelPos < 85) {
return Color(WheelPos * 3, 255 – WheelPos * 3, 0);
} else if (WheelPos < 170) {
WheelPos -= 85;
return Color(255 – WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return Color(0, WheelPos * 3, 255 – WheelPos * 3);
}
}