SuperKitz.com Project Manual
Arduino Christmas Tree WS2812 Neopixel LED DIY Kit
Using Arduino Nano and LED
This project allows you to create some cool light effects with Adafruit Neopixel WS2812. Using simple basic commands using Adafuit Library, we can design low cost LED dancing lights especially if you are not able to program a simple Arduino. Here is we are going to build a holiday tree using foam board which is decorated with Neopixel LED. Pressing a button changes the lights colour.
Requirements :
● Computer with an internet connection
● Download and install Arduino IDE
Components
Arduino Nano
USB 2.0 Male to Mini USB Cable
Jumper wires
12mm Push microswitch
WS2812 Neopixel
Mini Breadboard
Hardware
ARDUINO NANO
The Arduino Nano is basically a mini arduino uno which has all the capabilities as it is also made with the came chip atmega328 but in a SMD package .We are able to connect and give power to it through the MINI-B usb cable port.
Getting
Started with
Arduino Nano
Another wonderful feature of the arduino is the option of using a add-on boards to the arduino which comes as a module and they are known as “Shields”
Pin out diagram
Arduino Nano
Circuit Diagram
Wire up the Neopixel LED and microSwitch
With Arduino
Here we are using a micro push switch 12mm to select the song.
Print Paper Template [A4 ]
Here is a printable template.
Getting started with Arduino
Before starting any project, we need to interface Arduino with a computer. So we have to write and compile code for the Arduino to execute, as well as providing Arduino to function with the computer.
Installing The Arduino Software Package On Windows
Download a version of Arduino software suitable for your version of Windows from Arduino website / superkitzs.com. After downloading, check the instructions below to install the Arduino Integrated Development Environment (IDE).
CONNECT YOUR ARDUINO UNO BOARD WITH AN A B USB CABLE; SOMETIMES THIS CABLE IS CALLED A USB PRINTER CABLE
In order to upload code to the ESP8266 and use the serial console, connect any data-capable micro USB cable to ESP8266 IOT Board and the other side to your computer’s USB port.
The new version NodeMCUv1.0 comes with the CP2102 serial chip, you can download (also provided with the kit) and install the driver from https://www.silabs.com/products/development-tools/…. The NodeMCUv0.9 comes with the CH340 serial chip, you can download and install the driver from: https://github.com/nodemcu/nodemcu-devkit/tree/mas…
Install Library for Arduino IDE
Install Adafruit_NeoPixel as a ZIP file in Arduino IDE
Download FastLED 3.3 Library by clicking the button: Download Adafruit_NeoPixel
- In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library. At the top of the drop down list, select the option to “Add .ZIP Library‘‘.
- Then select the library zip file you have downloaded.
- Return to the Sketch > Include Library menu. menu. You should now see the library at the bottom of the drop-down menu. It is ready to be used in your sketch. The zip file will have been expanded in the libraries folder in your Arduino sketches directory.
Select your board type : Arduino Nano and port
Choose Tools | Serial Port menu. This is likely to be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find out, you can disconnect your board and re-open the menu; the entry that disappears should be the Arduino board. Reconnect the board and select that serial port
Press CNTRL + A and press DELETE on keyboard for clearing the Arduino IDE page
Upload the program
Copy the Sketch Code given below And try to understand
After that click on the “Upload” button. Then we can see the RX and TX LED on the board flashing. The message “Done uploading.” will appear if the uploading is a success
Arduino Programming
Sketch Code
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define DATA_PIN 6
#define NUMPIXELS 9
#define SWITCH 2
int MODE = 0;
int COLOUR = 0;
Adafruit_NeoPixel pixels(NUMPIXELS, DATA_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif
pixels.begin();
pixels.clear();
pixels.show();
}
void loop() {
check();
MODE_CHANGE();
}
void fade() {
for (int x = 0; x < NUMPIXELS; x++) {
for (int j = 0; j < 255; j++) {
pixels.setPixelColor(x, pixels.Color(j, 0, 0));
pixels.show();
check();
delay(2);
}
}
for (int x = 0; x < NUMPIXELS; x++) {
for (int j = 255; j > 0; j--) {
pixels.setPixelColor(x, pixels.Color(j, 0, 0));
pixels.show();
check();
delay(2);
}
}
for (int b = 0; b < NUMPIXELS; b++) {
for (int j = 0; j < 255; j++) {
pixels.setPixelColor(b, pixels.Color(0, j, 0));
pixels.show();
check();
delay(2);
}
}
for (int b = 0; b < NUMPIXELS; b++) {
for (int j = 255; j > 0; j--) {
pixels.setPixelColor(b, pixels.Color(0, j, 0));
pixels.show();
check();
delay(2);
}
}
for (int b = 0; b < NUMPIXELS; b++) {
for (int j = 0; j < 255; j++) {
pixels.setPixelColor(b, pixels.Color(0, 0, j));
pixels.show();
check();
delay(2);
}
}
for (int b = 0; b < NUMPIXELS; b++) {
for (int j = 255; j > 0; j--) {
pixels.setPixelColor(b, pixels.Color(0, 0, j));
pixels.show();
check();
delay(2);
}
}
}
void MODE_CHANGE() {
switch (MODE) {
case 1:
for (int x = 0; x < NUMPIXELS; x++) {
pixels.setPixelColor(x, pixels.Color(0, 255, 0));
pixels.show();
delay(50);
}
break;
case 2:
for (int x = 0; x < NUMPIXELS; x++) {
pixels.setPixelColor(x, pixels.Color(255, 0, 0));
pixels.show();
delay(50);
}
break;
case 3:
for (int x = 0; x < NUMPIXELS; x++) {
pixels.setPixelColor(x, pixels.Color(0, 0, 255));
pixels.show();
delay(50);
}
break;
case 4:
RAINBOW();
delay(50);
break;
case 5:
fade();
break;
case 6:
MODE = 0;
break;
}
}
void check() {
if (digitalRead(SWITCH) == 1) {
MODE++;
delay(10);
while (digitalRead(SWITCH) == 1);
}
}
void RAINBOW() {
pixels.setPixelColor(random(0, 9), pixels.Color(random(0, 20), random( 0, 20), random(0, 20)));
pixels.show();
delay(50);
}
Output
LED is light up in a pattern defined in the programme.