Project tutorial
Colour Change Outdoor Christmas Lights

Colour Change Outdoor Christmas Lights © CC BY-NC

Ten-year old nephews are particularly impressed when they can change the colour of the outdoor Christmas lights from a tablet.

  • 2 views
  • 0 comments
  • 0 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

About this project

Holiday guests choose the colour of the lights on the outdoor tree. Family marvels at the Internet of Things (and how nerdy you are, see ulyssesandbloom.ca). Neighbours appreciate the scintillation of small sparks twisting in the wind.

The NeoPixels held up over a month of snow and wind.

Light wire makes them easy to place in the tree. Since NeoPixels are one-sided, different lights are seen from different vantage points. The display seems to change as you walk by. The pixels appear to be illuminated or extinguished as they rotate in the wind.

Code

Christmas Light SketchArduino
/* 
  Sketch generated by the Arduino IoT Cloud Thing "Christmas"
  https://create.arduino.cc/cloud/things/XXXXXX 

  Arduino IoT Cloud Properties description

  The following variables are automatically generated and updated when changes are made to the Thing properties

  bool light;
  int red;
  int blue;
  int green;

  Properties which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"
#include <Adafruit_NeoPixel.h>
#define LED_PIN    6 //Which pin on the Arduino is connected to the NeoPixels?
#define LED_COUNT 4 // How many NeoPixels are attached to the Arduino?
int btnState;
int btnPrevState = 0;

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)

void setup() {
  pinMode(LED_PIN, OUTPUT);

  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
  
  strip.begin(); //call begin() to prepare the data pin for NeoPixel output:
  strip.setBrightness(64); 
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  if (light == 1) {
  strip.setPixelColor(0, red, green, blue); //strip.setPixelColor(n, red, green, blue);
  strip.setPixelColor(1, red, green, blue);
  strip.setPixelColor(2, red, green, blue);
  strip.setPixelColor(3, red, green, blue);
  strip.show();
  } else {
    uint32_t off  = strip.Color(0,0,0);
    strip.fill(off, 0, 4);
    strip.show();
  }
}

void onGreenChange() {
  // Do something
  Serial.print("Green = ");
  Serial.println(green);
}

void onRedChange() {
  // Do something
  Serial.print("Red = ");
  Serial.println(red);
}

void onBlueChange() {
  // Do something
  Serial.print("Blue = ");
  Serial.println(blue);
}

void onLightChange() {
  // Do something
  digitalWrite(LED_PIN, light);
    Serial.print("The light is ");
    if (light) {
        Serial.println("ON");
        
    } else {
        Serial.println("OFF");
    }
}
thingProperties.hArduino
The Arduiono IoT Cloud automatically creates these properties.
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>


const char THING_ID[] = "XXXX";

const char SSID[]     = SECRET_SSID;    // Network SSID (name)
const char PASS[]     = SECRET_PASS;    // Network password (use for WPA, or use as key for WEP)

void onLightChange();
void onRedChange();
void onBlueChange();
void onGreenChange();

bool light;
int red;
int blue;
int green;

void initProperties(){

  ArduinoCloud.setThingId(THING_ID);
  ArduinoCloud.addProperty(light, READWRITE, ON_CHANGE, onLightChange);
  ArduinoCloud.addProperty(red, READWRITE, ON_CHANGE, onRedChange);
  ArduinoCloud.addProperty(blue, READWRITE, ON_CHANGE, onBlueChange);
  ArduinoCloud.addProperty(green, READWRITE, ON_CHANGE, onGreenChange);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

Custom parts and enclosures

Ice Cream Container
An ice cream container kept the weather off the board. Leaves made good camouflage.
Img 2625a rcn2g3dteq

Schematics

Circuit
Data sent from pin 6, across a 220ohm resistor, to three strands of lights.
Power from VCC, over the 1,000uF capacitor, and to ground. Three strands connected: positive to positive, and negative to negative.
Extra wiring and buttons towards my thumb is extraneous. It was left over from experiments.
Img 2633 1o3fywvuxt
Soldering NeoPixel
Solder four NeoPixels in a strand of four lights. The light wire hangs easily on a tree branch.
Img 2624a yg6c9kvudm
Properties
Set these properties in the Arduino IoT Cloud
Img 2627 lk4qiguiws

Comments

Similar projects you might like

DIY Christmas Tree and Christmas Decor Using Arduino

Project tutorial by STEMpedia

  • 1,309 views
  • 0 comments
  • 5 respects

Huge LED Christmas Lights

Project showcase by Savva Osipov

  • 14,168 views
  • 2 comments
  • 39 respects

Christmas Presents Intruder Detector

Project tutorial by David Escobar

  • 4,342 views
  • 5 comments
  • 12 respects

Programmable Christmas Mason Jar Lights

Project tutorial by Katie Kristoff

  • 2,887 views
  • 0 comments
  • 16 respects

Christmas and More Lights

Project tutorial by FunguyPro

  • 2,113 views
  • 0 comments
  • 4 respects

Turn Lights On When Approaching Home

Project tutorial by Andrei Florian

  • 17,730 views
  • 34 comments
  • 52 respects
Add projectSign up / Login