Introduction: The Complete NeoPixel Guide

Picture of The Complete NeoPixel Guide

NeoPixel's are awesome you can control hundreds, thousands, millions of lights with 3 wires (pwr, signal, gnd). I created this instructable to provide people with a basic to complex understanding of how to make NeoPixels Rock! I used the fallowing to make mine work : Arduino Uno, 3 wires, and a neopixel strand. There are only 3-easy steps to make this work!!

Step 1: First Things First, Install the Library

Picture of First Things First, Install the Library

You will first need to download the library and install it click here to download the library free. Then copy the folder to your arduino library folder.(most likely at this path: C:\Program Files (x86)\Arduino\libraries)

The library should be installed now and now you can program the arduino!

Step 2: Program the Arduino

Picture of Program the Arduino

Download the Code Here

The code I used is simple once you understand it

You first need to define the strip params:

Adafruit_NeoPixel strip = Adafruit_NeoPixel(COUNT, PIN, NEO_GRB + NEO_KHZ800);


Then start the strip library:

strip.begin();


So you can finally control each pixel color:

uint32_t color = strip.Color(R2, G2, B2);
strip.setPixelColor(Pixel, color);
strip.show();


This is the code that i wrote - i commented on each part so you can understand how it works!


#include
#define PIN 3 // the pin your strip is connected to
#define COUNT 36 // how many led's are on that strip
Adafruit_NeoPixel strip = Adafruit_NeoPixel(COUNT, PIN, NEO_GRB + NEO_KHZ800); //defines the strips properties
int R;
int G;
int B;
void setColor(int Pixel, int R2, int G2, int B2) {
uint32_t color = strip.Color(R2, G2, B2); // make a color
strip.setPixelColor(Pixel, color); //set a single pixel color
strip.show(); //update the colors
}
void doShow() {
for (int i = 0; i < COUNT; i++) {
setColor(i, 0, 0, 0);
}
for (int i = 0; i < COUNT; i++) {
setColor(i, 255, 0, 0); //turn all to red
delay(50);
}
for (int i = 0; i < COUNT; i++) {
setColor(i, 0, 255, 0); //turn all to blue
delay(50);
}
for (int i = 0; i < COUNT; i++) {
setColor(i, 0, 0, 255); //turn all to green
delay(50);
}
for (int i = 0; i < COUNT; i++) {
setColor(i, 255, 247, 0); //turn all to yellow
delay(50);
}
for (int i = 0; i < COUNT; i++) {
setColor(i, 255, 100, 0); //turn all to orange
delay(50);
}
for (int i = 0; i < COUNT; i++) {
setColor(i, 255, 0, 205); //turn all to purple
delay(50);
}
for (int i = 0; i < COUNT; i++) {
setColor(i, 0, 213, 255); //turn all to turquoise
delay(50);
}
if (Serial.available() < 0) {
doShow();
}
}
void setup() {
strip.begin(); // start the strip
strip.show(); // set the strip to black (because we havent told it to do anything yet)
Serial.begin(9600);
Serial.println("ready to change color");
}
void loop() {
if (Serial.available() > 0) { // if bytes are available through the serial port
char c = Serial.read(); //read the first byte
if (c == 'R') {
R = Serial.parseInt(); //get the INT
}
if (c == 'G') {
G = Serial.parseInt(); //get the INT
}
if (c == 'B') {
B = Serial.parseInt(); //get the INT
}
if (c == 'P') {
setColor(Serial.parseInt(), R, G, B);
}
if (c == 'S') {
doShow();
}
}
}

Step 3: Control the Lights

Picture of Control the Lights

Open your serial port

if you send 'R255G0B0P0' the first led will be red, let me break it down though

'R' stands for red so if you send 'R255' Red will be set to 255

'G' stands for green so if you send 'G255' Green will be set to 255

'B' stands for blue so if you send 'B255' Blue will be set to 255

'P' stands for pixel so when you send that the UNO will write a pixel color for example if you send 'P1' the first pixel will be set to whatever color you have assigned

you can send as many commands at once such as this: 'R100G100B255P0P1P2P3P4P5P6P7P8P9P10' - this will set pixels 0-10 to Bright Blue

if you send 'S' you will be greted with a show of Red, Blue, Green, Yellow, Orange, Purple, and Turquoise lights! watch the video to see

Simple as that, feel free to try new things with the code it can only help :)

Comments

About This Instructable

1,395views

27favorites

License:

Bio: I like to create new things! I'm very interested in IOT and just Internet Stuff. I am not responsible for any injury or deaths ... More »
More by Funguypro:3D Print Your House!!!!!DIY Raspberry Pi Indoor Outdoor WebcamSee Through Buildings With a Drone
Add instructable to: