The Complete NeoPixel Guide

The Complete NeoPixel Guide © CC BY-NC-SA

NeoPixel's are awesome you can control hundreds, thousands, millions of lights with 3 wires (pwr, signal, gnd). Let's learn how to use them!

  • 8,210 views
  • 5 comments
  • 19 respects

Components and supplies

Apps and online services

About this project

NeoPixel's are awesome you can control hundreds, thousands, millions of lights with 3 wires (pwr, signal, gnd). I created this tutorial 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

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

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();

In the code section you will find the code I wrote, commented for your easy understanding.

Step 3: 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 greeted 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.

Code

Neopixel Arduino
#include <Adafruit_NeoPixel.h>  
#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();
}
}
}

Comments

Similar projects you might like

NeoPixel LEDs: Arduino Basics

by Alex Glow

  • 43,196 views
  • 1 comment
  • 46 respects

Neopixel LED Eyeball Controlled by Nunchuck

Project tutorial by HomeMadeGarbage

  • 5,274 views
  • 7 comments
  • 28 respects

How to Make a NeoPixel Matrix

Project tutorial by Arduino “having11” Guy

  • 4,484 views
  • 3 comments
  • 13 respects

Neopixel Motion Activated Night Light

Project tutorial by Becky Ellis

  • 2,492 views
  • 4 comments
  • 9 respects

Simple wall clock using Adafruit 1/4 60 Ring Neopixel

Project tutorial by antiElectron

  • 6,691 views
  • 0 comments
  • 34 respects
Add projectSign up / Login