Christmas Sweater

Christmas Sweater

I will be showing you how to make your own wired LEDs for Christmas Sweater.

  • 473 views
  • 0 comments
  • 2 respects

Components and supplies

About this project

Christmas Sweater

Cut all the led pins by half and connect the jumper wires according to the matching colors. same goes for regular LEDs.

Cover the LEDs using shrink tube and use the heatgun to shrink it. Use a smaller shrink tube for the non-RGB LEDs as it only has two pins.

Building the demo board

For the demo I've put together, I've placed five addressable LEDs in a breadboard. Connected the Power and Ground rails of the breadboard to my Arduino Uno, and then daisy-chained the LEDs together, one Data Out to the next Data In.

The Adafruit library has two specific calls that you need to understand to use these LEDs. The first sets the colors to encode into the signal, and the second actually sends the signal.

Remember that like with most things in programming, you start with ZERO as the first item of the count, so... if I wanted to show a rainbow of colors on my five LEDs, I'd do this:

strip.setPixelColor(0, 255, 0, 0); // Red

strip.setPixelColor(1, 255, 69, 0); // Orange

strip.setPixelColor(2, 255, 255, 0); // Yellow

strip.setPixelColor(3, 0, 255, 0); // Green

strip.setPixelColor(4, 0, 0, 255); // Blue

The four values in the parentheses are: LED#, Red Color, Green Color, and Blue Color. The LED# starts with 0, and makes the use of a For Statement in programs easy. In fact in the example code that comes with the library, all of the calls to the strip.setPixelColor() command are nested in For Statements.

More information you'll find in the sketch. Good luck!

Code

Untitled fileC/C++
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel strip = Adafruit_NeoPixel(5, 6, NEO_RGB + NEO_KHZ800);

// The three parameters passed here are: Number of LEDs, Arduino Pin, Config information.
// For more help on the Config details, see the Example sketch provided with the Adafruit NeoPixel library.

#include "pitches.h"

// This library allows for the easy translation of musical notes to their matching frequencies.
// There is a "two bit" example sketch provided with the Arduino IDE.

int wait = 500;  // This will govern how long the tones will be, and the pauses between tones.
float reduct = .85; // This will govern how quickly it speeds up.
int ending = 0; // This is a simple token to tell the Sketch when its done.

void setup() {
  // When power is first applied to the LEDs they will show a color based on the voltage being sent to them.  
  strip.begin();
  strip.show();
  
  // We initalize the NeoPixel Library here, by starting it and then sending the first strip.show() command.
  // Next we will tell all of the LEDs to switch off before continuing.
  
  pcr(); // PixelColorsReset function, it turns all of the LEDs completely off.
         // This custom function can be found at the bottom of this Sketch.

  // We play the melody once during setup with all 5 LEDs lighting up in the color for the tone being played.
  
  strip.setPixelColor(0, 100, 0, 0);
  strip.setPixelColor(1, 100, 0, 0);
  strip.setPixelColor(2, 100, 0, 0);
  strip.setPixelColor(3, 100, 0, 0);
  strip.setPixelColor(4, 100, 0, 0);
  strip.show();
  tone(8, NOTE_G4); // this starts the tone
  delay(wait);
  noTone(8); // this stops the tone
  pcr();
  delay(wait/10);
  
  strip.setPixelColor(0, 170, 80, 10);
  strip.setPixelColor(1, 170, 80, 10);
  strip.setPixelColor(2, 170, 80, 10);
  strip.setPixelColor(3, 170, 80, 10);
  strip.setPixelColor(4, 170, 80, 10);
  strip.show();
  tone(8, NOTE_A4);
  delay(wait);
  noTone(8);
  pcr();
  delay(wait/10);
  
  strip.setPixelColor(0, 120, 0, 200);
  strip.setPixelColor(1, 120, 0, 200);
  strip.setPixelColor(2, 120, 0, 200);
  strip.setPixelColor(3, 120, 0, 200);
  strip.setPixelColor(4, 120, 0, 200);
  strip.show();
  tone(8, NOTE_F4);
  delay(wait);
  noTone(8);
  pcr();
  delay(wait/10);
  
  strip.setPixelColor(0, 128, 120, 0);
  strip.setPixelColor(1, 128, 120, 0);
  strip.setPixelColor(2, 128, 120, 0);
  strip.setPixelColor(3, 128, 120, 0);
  strip.setPixelColor(4, 128, 120, 0);
  strip.show();
  tone(8, NOTE_F3);
  delay(wait);
  noTone(8);
  pcr();
  delay(wait/10);
  
  strip.setPixelColor(0, 140, 180, 180);
  strip.setPixelColor(1, 140, 180, 180);
  strip.setPixelColor(2, 140, 180, 180);
  strip.setPixelColor(3, 140, 180, 180);
  strip.setPixelColor(4, 140, 180, 180);
  strip.show();
  tone(8, NOTE_C4);
  delay(wait);
  noTone(8);
  pcr();
  // We don't need a delay at the end here, as the next iteration of the loop delays at the start.
  
}

void loop() {
  
  // The melody has played in the setup loop, so we will play it again and again getting faster every time until its too fast.
  
  if (wait > 40) {
    
    delay(wait);
    
    notes();  // this custom function plays the tones with only one LED lighting up per tone.
              // The function itself is at the bottom of this Sketch.
              
    wait *= reduct;  // after the function returns, we decrease the wait time for the next loop
    
  } else {
    
    if (ending == 0) {
      // Once the wait varible is less than 40 we will play the melody one last time, with all the LEDs lit and at a set duration.
      // Then increment the ending varible so that the Sketch goes dark and silent until reset.  
      delay(2500);
      strip.setPixelColor(0, 100, 0, 0);
      strip.setPixelColor(1, 100, 0, 0);
      strip.setPixelColor(2, 100, 0, 0);
      strip.setPixelColor(3, 100, 0, 0);
      strip.setPixelColor(4, 100, 0, 0);
      strip.show();
      tone(8, NOTE_G3);
      delay(500);
      noTone(8);
      pcr();
      delay(50);
      
      strip.setPixelColor(0, 170, 80, 10);
      strip.setPixelColor(1, 170, 80, 10);
      strip.setPixelColor(2, 170, 80, 10);
      strip.setPixelColor(3, 170, 80, 10);
      strip.setPixelColor(4, 170, 80, 10);
      strip.show();
      tone(8, NOTE_A3);
      delay(500);
      noTone(8);
      pcr();
      delay(50);
      
      strip.setPixelColor(0, 120, 0, 200);
      strip.setPixelColor(1, 120, 0, 200);
      strip.setPixelColor(2, 120, 0, 200);
      strip.setPixelColor(3, 120, 0, 200);
      strip.setPixelColor(4, 120, 0, 200);
      strip.show();
      tone(8, NOTE_F3);
      delay(500);
      noTone(8);
      pcr();
      delay(50);
      
      strip.setPixelColor(0, 128, 120, 0);
      strip.setPixelColor(1, 128, 120, 0);
      strip.setPixelColor(2, 128, 120, 0);
      strip.setPixelColor(3, 128, 120, 0);
      strip.setPixelColor(4, 128, 120, 0);
      strip.show();
      tone(8, NOTE_F2);
      delay(500);
      noTone(8);
      pcr();
      delay(50);
      
      strip.setPixelColor(0, 140, 180, 180);
      strip.setPixelColor(1, 140, 180, 180);
      strip.setPixelColor(2, 140, 180, 180);
      strip.setPixelColor(3, 140, 180, 180);
      strip.setPixelColor(4, 140, 180, 180);
      strip.show();
      tone(8, NOTE_C3);
      delay(1500);
      noTone(8);
      pcr();
      ending++;
  
    }
  }
}
  
void pcr() {
  // This function turns all the LEDs off, reseting them.
  // I wrote this function to overcome the only real shortcomming I saw in the Adafruit Library, a reset command.
  strip.setPixelColor(0, 0, 0, 0);
  strip.setPixelColor(1, 0, 0, 0);
  strip.setPixelColor(2, 0, 0, 0);
  strip.setPixelColor(3, 0, 0, 0);
  strip.setPixelColor(4, 0, 0, 0);
  strip.show();
  return;
}

void notes() {
  
  // This function plays the melody, lighting up only the LED that corresponds to the tone played.
  pcr();
  strip.setPixelColor(0, 100, 0, 0);
  strip.setPixelColor(1, 0, 0, 0);
  strip.setPixelColor(2, 0, 0, 0);
  strip.setPixelColor(3, 0, 0, 0);
  strip.setPixelColor(4, 0, 0, 0);
  strip.show();
  tone(8, NOTE_G4);
  delay(wait);
  noTone(8);
  pcr();
  delay(wait/10);
  
  strip.setPixelColor(0, 0, 0, 0);
  strip.setPixelColor(1, 170, 80, 10);
  strip.setPixelColor(2, 0, 0, 0);
  strip.setPixelColor(3, 0, 0, 0);
  strip.setPixelColor(4, 0, 0, 0);
  strip.show();
  tone(8, NOTE_A4);
  delay(wait);
  noTone(8);
  pcr();
  delay(wait/10);
  
  strip.setPixelColor(0, 0, 0, 0);
  strip.setPixelColor(1, 0, 0, 0);
  strip.setPixelColor(2, 120, 0, 200);
  strip.setPixelColor(3, 0, 0, 0);
  strip.setPixelColor(4, 0, 0, 0);
  strip.show();
  tone(8, NOTE_F4);
  delay(wait);
  noTone(8);
  pcr();
  delay(wait/10);
  
  strip.setPixelColor(0, 0, 0, 0);
  strip.setPixelColor(1, 0, 0, 0);
  strip.setPixelColor(2, 0, 0, 0);
  strip.setPixelColor(3, 128, 120, 0);
  strip.setPixelColor(4, 0, 0, 0);
  strip.show();
  tone(8, NOTE_F3);
  delay(wait);
  noTone(8);
  pcr();
  delay(wait/10);
  
  strip.setPixelColor(0, 0, 0, 0);
  strip.setPixelColor(1, 0, 0, 0);
  strip.setPixelColor(2, 0, 0, 0);
  strip.setPixelColor(3, 0, 0, 0);
  strip.setPixelColor(4, 140, 180, 180);
  strip.show();
  tone(8, NOTE_C4);
  delay(wait);
  noTone(8);
  pcr();
  return;

}

Schematics

Untitled file

No document.

Comments

Similar projects you might like

MKR1000 Christmas IoTree with Cayenne Project Builder

Project tutorial by Benny Estes

  • 2,880 views
  • 3 comments
  • 9 respects

Christmas Tree Water Level via Cayenne and MKR1000

Project showcase by Ian Zahn

  • 1,918 views
  • 0 comments
  • 2 respects

Hackable Christmas Greeting Card

Project tutorial by Neoxelox

  • 1,713 views
  • 0 comments
  • 3 respects

Arduino MKR1000 + Android + Relay = Christmas gift lock

Project tutorial by Ahmed Hamdy

  • 1,439 views
  • 0 comments
  • 9 respects

Christmas Presents Intruder Detector

Project tutorial by David Escobar

  • 3,733 views
  • 5 comments
  • 12 respects

IoT Christmas Tree Topper

Project tutorial by Balázs Simon

  • 1,564 views
  • 0 comments
  • 9 respects
Add projectSign up / Login